| | |
| | | >远程调试 |
| | | </el-button> |
| | | </template> |
| | | <!-- 添加行政区划显示模板 --> |
| | | <template #area_code="{ row }"> |
| | | <span>{{ row.area_name }}</span> |
| | | </template> |
| | | </avue-crud> |
| | | |
| | | <el-dialog title="固件升级" append-to-body v-model="firmwareBox" width="455px"> |
| | |
| | | props: { |
| | | label: 'title', |
| | | value: 'value', |
| | | emitPath: false, |
| | | checkStrictly: true, |
| | | multiple: false, |
| | | expandTrigger: 'hover', |
| | | }, |
| | | dataType: 'string', |
| | | rules: [ |
| | | { |
| | | required: true, |
| | | message: '请选择所在省份', |
| | | trigger: 'blur', |
| | | message: '请选择行政区划', |
| | | trigger: 'change', |
| | | }, |
| | | ], |
| | | change: ({ value }) => { |
| | | if (!value) { |
| | | this.form.area_code = null; |
| | | } else { |
| | | if (typeof value === 'string' && value.includes(',')) { |
| | | const codes = value.split(','); |
| | | this.form.area_code = codes[codes.length - 1]; |
| | | } else { |
| | | this.form.area_code = value; |
| | | } |
| | | } |
| | | }, |
| | | lazy: true, |
| | | lazyLoad(node, resolve) { |
| | | let level = node.level; |
| | | let list = []; |
| | | let callback = () => { |
| | | resolve( |
| | | (list || []).map(ele => { |
| | | return Object.assign(ele, { |
| | | leaf: !ele.hasChildren, |
| | | }); |
| | | }) |
| | | (list || []).map(ele => ({ |
| | | ...ele, |
| | | value: ele.value, |
| | | leaf: level >= 2, |
| | | })) |
| | | ); |
| | | }; |
| | | if (level == 0) { |
| | | |
| | | if (level === 0) { |
| | | getLazyTree('000000000000').then(res => { |
| | | list = res.data.data; |
| | | callback(); |
| | | }); |
| | | } else if (level > 0 && level < 5) { |
| | | } else if (level === 1) { |
| | | getLazyTree(node.value).then(res => { |
| | | list = res.data.data; |
| | | callback(); |
| | | }); |
| | | } else if (level === 2) { |
| | | getLazyTree(node.value).then(res => { |
| | | list = res.data.data; |
| | | callback(); |
| | |
| | | this.ossSetBox = false; |
| | | }, |
| | | rowSave(row, done, loading) { |
| | | let areaCode = row.area_code; |
| | | if (Array.isArray(areaCode)) { |
| | | areaCode = areaCode[areaCode.length - 1]; |
| | | } else if (typeof areaCode === 'string' && areaCode.includes(',')) { |
| | | const codes = areaCode.split(','); |
| | | areaCode = codes[codes.length - 1]; |
| | | } |
| | | row.area_code = areaCode || null; |
| | | |
| | | add(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | |
| | | ); |
| | | }, |
| | | rowUpdate(row, index, done, loading) { |
| | | update(row).then( |
| | | const submitData = { |
| | | ...row, |
| | | area_code: row.area_code.split(',').pop(), |
| | | }; |
| | | |
| | | update(submitData).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | |
| | | this.$refs.crud.toggleSelection(); |
| | | }); |
| | | }, |
| | | getFullAreaCode(areaCode) { |
| | | if (!areaCode) return ''; |
| | | |
| | | const code = areaCode.toString(); |
| | | |
| | | if (code.includes(',')) return code; |
| | | |
| | | if (code.endsWith('0000000000')) { |
| | | return code; |
| | | } else if (code.endsWith('00000000') && !code.endsWith('0000000000')) { |
| | | const provinceCode = code.substring(0, 2) + '0000000000'; |
| | | return `${provinceCode},${code}`; |
| | | } else { |
| | | const provinceCode = code.substring(0, 2) + '0000000000'; |
| | | const cityCode = code.substring(0, 4) + '00000000'; |
| | | return `${provinceCode},${cityCode},${code}`; |
| | | } |
| | | }, |
| | | beforeOpen(done, type) { |
| | | if (['edit', 'view'].includes(type)) { |
| | | getDetail(this.form.id).then(res => { |
| | | this.form = res.data.data; |
| | | const data = res.data.data; |
| | | this.form = { |
| | | ...data, |
| | | area_code: this.getFullAreaCode(data.area_code), |
| | | }; |
| | | }); |
| | | } |
| | | done(); |