123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- export default function getAttributeDetail (payload = {}) {
- return new Promise(async (resolve) => {
- // 属性
- const attributeComponentData = {
- nodeType: 'item',
- required: true,
- label: '属性',
- nodeList: [
- {
- nodeType: 'select',
- keyword: 'attribute_category_id',
- hub: 'attribute-detail',
- props: {
- placeholder: '选择属性',
- },
- },
- ],
- }
- // 名称
- const nameComponentData = {
- nodeType: 'item',
- required: true,
- label: `${payload.attribute_type ? '参数' : '规格'}名称`,
- nodeList: [
- {
- nodeType: 'input',
- keyword: 'name',
- hub: 'attribute-detail',
- props: {
- placeholder: `输入${payload.attribute_type ? '参数' : '规格'}名称`,
- },
- },
- ],
- }
- // 可选列表
- const listComponentData = {
- nodeType: 'item',
- required: false,
- size: 'large',
- label: '可选列表',
- nodeList: [
- {
- nodeType: 'inputTag',
- keyword: 'input_list',
- hub: 'attribute-detail',
- props: {},
- },
- ],
- }
- // 手动新增
- const handComponentData = {
- nodeType: 'item',
- required: true,
- label: '商家手动新增',
- nodeList: [
- {
- nodeType: 'radioGroup',
- keyword: 'hand_add_status',
- hub: 'attribute-detail',
- props: {},
- },
- ],
- }
- // 排序
- const sortComponentData = {
- nodeType: 'item',
- required: true,
- label: '排序',
- nodeList: [
- {
- nodeType: 'inputNumber',
- keyword: 'sort',
- hub: 'attribute-detail',
- props: {
- min: 1,
- },
- },
- ],
- }
- // 整体组件数据
- const componentData = [
- attributeComponentData,
- nameComponentData,
- listComponentData,
- handComponentData,
- sortComponentData,
- ]
- const value = {
- attribute_type: payload.attribute_type,
- name: null,
- attribute_category_id: null,
- input_list: [],
- hand_add_status: null,
- sort: 999,
- }
- const error = {}
- const option = {
- attribute_category_id: {
- type: 'async',
- list: [],
- },
- hand_add_status: {
- list: [],
- },
- }
- value.attribute_category_id = payload.attribute_category_id
- option.attribute_category_id.list = [
- {
- value: payload.attribute_category_id,
- label: payload.attribute_category_name,
- },
- ]
- if (payload.id) {
- value.id = payload.id
- value.name = payload.name
- value.input_list = payload.input_list.split(',')
- value.hand_add_status = payload.hand_add_status
- value.sort = payload.sort
- }
- const attributeDetailData = {
- componentData,
- value,
- error,
- option,
- }
- resolve(attributeDetailData)
- })
- }
|