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IAAI,CAAC,IAAI;oBAC1C,KAAK;oBACL,KAAK,EAAE,KAAK,KAAK,KAAK,IAAI,MAAM,KAAK,UAAU;oBAC/C,MAAM;oBACN,KAAK;oBACL,WAAW,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,KAAK;iBACxC,CAAC,CAAC;YACL,CAAC;YACD,KAAK;gBACH,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;SACF,CAAC;IACJ,CAAC;CAAA,CAAA;AA3JoB,QAAQ;IAD5B,WAAW,EAAE;GACO,QAAQ,CA2J5B;eA3JoB,QAAQ","file":"step-item.js","sourcesContent":["import { wxComponent, SuperComponent, RelationsOptions } from '../common/src/index';\nimport config from '../common/config';\nimport props from './step-item-props';\n\nconst { prefix } = config;\n\n@wxComponent()\nexport default class StepItem extends SuperComponent {\n options = {\n multipleSlots: true,\n };\n\n relations: RelationsOptions = {\n './steps': {\n type: 'ancestor',\n },\n };\n\n externalClasses = [\n `${prefix}-class`,\n `${prefix}-class-content`,\n `${prefix}-class-title`,\n `${prefix}-class-description`,\n `${prefix}-class-extra`,\n ];\n\n properties = props;\n\n // 组件的内部数据\n data = {\n classPrefix: `${prefix}-steps-item`,\n prefix,\n rootClassName: '',\n parent: null,\n index: 0,\n isDot: false,\n curStatus: '',\n curSubStepItems: [],\n layout: 'vertical',\n type: 'default',\n isLastChild: false,\n isLarge: false,\n readonly: false,\n computedIcon: '',\n };\n\n observers = {\n icon(val) {\n this.setData({\n computedIcon: val,\n });\n },\n };\n\n lifetimes = {\n ready() {\n const [parent] = this.getRelationNodes('./steps') || [];\n\n if (parent) {\n this.setData({\n parent,\n });\n }\n },\n };\n\n methods = {\n updateStatus(current, currentStatus, index, theme, layout, steps, readonly) {\n const { status } = this.data;\n const _current = String(current);\n const firstStep = Number(_current.split('-')[0]);\n const secondStep = _current.split('-')[1] ? Number(_current.split('-')[1]) : undefined;\n\n // 判断对象的attr属性存在 && attr数组长度不为0\n const judgeObjAttr = (data, attr: string) => {\n return data[attr] && data[attr].length;\n };\n\n const judgeStepStatus = (itemIndex: number, current: number, status: string) => {\n if (itemIndex < current) return 'finish';\n if (itemIndex === current) return status;\n return 'default';\n };\n\n const changeStatus = (\n data,\n attr: string,\n itemAttr: string,\n status: string,\n value: number = data[attr].length,\n ) => {\n data[attr].forEach((item, index) => {\n item[itemAttr] = judgeStepStatus(index, value, status);\n });\n };\n\n const isLastChild = (data, index) => index === data.length - 1;\n\n // 1. 拷贝一份 substep\n if (judgeObjAttr(this.data, 'subStepItems')) {\n const _subStepItems = JSON.parse(JSON.stringify(this.data.subStepItems));\n this.data._subStepItems = _subStepItems;\n }\n\n // 2. 优先step的statue && 判断step及subStep状态\n if (status !== 'default') {\n this.data._status = status;\n } else if (status === 'default') {\n if (index < firstStep) {\n this.data._status = 'finish';\n judgeObjAttr(this.data, '_subStepItems') && changeStatus(this.data, '_subStepItems', '_status', 'finish');\n } else if (index === firstStep) {\n this.data._status = currentStatus;\n if (secondStep !== undefined && judgeObjAttr(this.data, '_subStepItems')) {\n changeStatus(this.data, '_subStepItems', '_status', currentStatus, secondStep);\n }\n\n // secondStep存在,子步骤条为default时,其stepItem状态应为process\n if (\n secondStep !== undefined &&\n currentStatus === 'finish' &&\n judgeObjAttr(this.data, '_subStepItems') &&\n !isLastChild(this.data._subStepItems, secondStep)\n ) {\n this.data._status = 'process';\n }\n\n // secondStep存在,子步骤条为finish且不为最后一个子步骤时,其stepItem状态应为proces\n if (secondStep !== undefined && currentStatus === 'default') {\n this.data._status = 'process';\n }\n } else if (index > firstStep) {\n this.data._status = 'default';\n judgeObjAttr(this.data, '_subStepItems') && changeStatus(this.data, '_subStepItems', '_status', 'default');\n }\n }\n\n // update icon\n let iconStatus = '';\n if (readonly) {\n if (this.data._status === 'finish') {\n iconStatus = 'check';\n } else if (this.data._status === 'error') {\n iconStatus = 'close';\n }\n }\n\n this.setData({\n curStatus: this.data._status || this.data.status,\n curSubStepItems: this.data._subStepItems || [],\n computedIcon: iconStatus || this.data.icon,\n index,\n isDot: theme === 'dot' && layout === 'vertical',\n layout,\n theme,\n isLastChild: steps.length - 1 === index,\n });\n },\n click() {\n this.data.parent.handleClick(this.data.index);\n },\n };\n}\n"]}
|