titles.map(item => ({title: item}))

本文介绍了一个使用JavaScript将数组元素转换为对象数组的例子。通过`map`函数遍历字符串数组,构造出具有`name`属性的对象数组,并展示了如何利用`console.log`输出最终结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

   <script>
        var titles=['kity','xiaohua','caimiao']
        const vtabs = titles.map(item => ({'name': item}))
        console.log(vtabs);
        // [ {name: "kity"}, {name: "xiaohua"},{name: "caimiao"}]
    </script>
return Array.from(sectionMap).map(([name, settings]) => ({ sectionName: name, settings }));这里有报错:Destructuring parameter declarations are not supported (arkts-no-destruct-params) <ArkTSCheck> ; const value = rawItem[key]; 这里 Use explicit types instead of "any", "unknown" (arkts-no-any-unknown) <ArkTSCheck> Indexed access is not supported for fields (arkts-no-props-by-index) <ArkTSCheck> , value: value.map((nestedItem: any) => {:Use explicit types instead of "any", "unknown" (arkts-no-any-unknown) <ArkTSCheck> ; const titles: Partial<Record<SettingKeys, string>> = { :Some of utility types are not supported (arkts-no-utility-types) <ArkTSCheck> ,Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck>;return titles[key] || key.toString(); :Indexed access is not supported for fields (arkts-no-props-by-index) <ArkTSCheck> ; private getTypeByKey(key: SettingKeys): UISettingItem['type'] { :Indexed access types are not supported (arkts-no-aliases-by-index) <ArkTSCheck> ; const descriptions: Partial<Record<SettingKeys, string>> = { captureLinkage: '抓拍时自动生成一段关联视频', speedOsd: '数据来源于GPS,设备需内置或扩展GPS模块', parkingMonitoringEnable: '停车后自动启动监控功能', parkingSensitivity: '灵敏度设置越高,监测越敏感但电池消耗更快', ADAS: '高级驾驶辅助系统设置', GPS: '全球定位系统配置', cellular: '移动网络配置', parkingMonitoringTime: '设置停车监控的最长持续时间', cloudBox: '云存储服务设置' }; return descriptions[key]; :Some of utility types are not supported (arkts-no-utility-types) <ArkTSCheck> Indexed access is not supported for fields (arkts-no-props-by-index) <ArkTSCheck> ; const newSections = this.sections.map(section => ({ ...section, settings: section.settings.map(item => item.key === key ? { ...item, value } : item :Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck> ,It is possible to spread only arrays or classes derived from arrays into the rest parameter or array literals (arkts-no-spread) <ArkTSCheck> ; Section({ :Cannot find name 'Section'. Did you mean 'section'? <ArkTSCheck> ; this.SettingGroup({ title: item.title, description: item.description, items: item.value as UISettingItem[] }) Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck>;:Object literal must correspond to some explicitly declared class or interface (arkts-no-untyped-obj-literals) <ArkTSCheck> ; this.SettingItem({ item: item, onChange: (value) => this.handleSettingChange(item.key, value) }) 'this.SettingItem({ item: item, onChange: (value) => this.handleSettingChange(item.key, value) })' does not comply with the UI component syntax. <ArkTSCheck> Property 'SettingItem' does not exist on type 'Configure'. <ArkTSCheck> ,请帮我修改,并给我完整代码
06-11
<template> <div class="addTaskModal" v-if="visible"> <editAndAddPage :router="'/basicConfiguration'" :title="titles" @cancel="cancel" @submit="submit"> <template v-slot:pageBody> <div class="main-body-box"> <a-form-model :label-col="{ span: 2 }" :wrapper-col="{ span: 22 }" ref="ruleForm" :rules="rules" :model="modalData" > <a-form-model-item label=""></a-form-model-item> <a-form-model-item :label="$t('任务名称:')" prop="taskName"> <a-input :placeholder="$t('请输入任务名称')" v-model="modalData.taskName" maxLength="25"> </a-input> </a-form-model-item> <a-form-model-item :label="$t('包含设备:')"> <Transfer ref="transferRef" :hostModel="modalData.hostModel"></Transfer> </a-form-model-item> <a-form-model-item :label="$t('空开配置:')"> <div class="config_content"> <div class="config_item" v-for="(item, index) in configArr" :key="index"> <div class="config_title"> <a-select v-model="item.configTypeCode" @change="handleConfigTypeChange($event, index)" :placeholder="$t('请选择')" > <a-select-option :value="el.configTypeCode" v-for="el in configTypeOptions" :disabled="el.disabled" :key="el.configTypeCode" :title="$t(el.configTypeName)" > {{ $t(el.configTypeName) }} </a-select-option> </a-select> <hd-icon type="delete" @click="delConfig(index)" /> </div> <div class="config_main"> <div class="type_info"> <span>{{ $t('操作类型:') }}</span> <a-radio-group v-model="item.cmd"> <a-radio-button value="0"> {{ $t('分闸') }}</a-radio-button> <a-radio-button value="1"> {{ $t('合闸') }} </a-radio-button> </a-radio-group> </div> <div class="time_info"> <span>{{ $t('时间范围:') }}</span> <a-time-picker class="mgb_12" format="HH:mm" valueFormat="HH:mm" v-model="item.excTime" :placeholder="$t('选择时间')" /> </div> <div class="week_info"> <span>{{ $t('运行周期:') }}</span> <div class="week_list"> <div class="week_item" v-for="(day, indx) in item.weekList" :key="indx" @click="toggleDay(day, item)" :class="{ selected: day.value == 1 }" > <div>{{ day.name }}</div> <div v-show="day.value == 1" class="triangle"></div> <div v-show="day.value == 1" class="checkmark"></div> </div> </div> </div> </div> </div> </div> <div class="addBtn" @click="addConfig"> <hd-icon type="add" /> {{ $t('新增空开配置') }} </div> </a-form-model-item> </a-form-model> </div> </template> </editAndAddPage> </div> </template> <script> import reg from '@/common/js/reg' import factory from '../factory' import Transfer from './Transfer.vue' import editAndAddPage from '@/components/scfComponents/editAndAddPage/editAndAddPage.vue' export default { components: { Transfer, editAndAddPage }, data() { return { titles: '新增空开定时任务', visible: false, modalData: { taskName: '', hostModel: undefined, }, rules: { taskName: [ { required: true, message: '请输入任务名称', trigger: 'blur' }, { pattern: reg.name, message: this.$t('仅允许输入汉字、字母、数字与_-.@字符') }, ], }, configTypeOptions: [], configArr: [], } }, computed: {}, mounted() {}, methods: { // 打开弹窗 showModal() { this.visible = true // 获取主机型号 this.modalData = { taskName: '', hostModel: undefined, } // 获取配置项 this.getConfigOptions() this.configArr = [ { configTypeCode: undefined, configTypeName: '', cmd: '', excTime: '', rept: '000000000', weekList: [ { name: this.$t('周日'), value: 0 }, { name: this.$t('周一'), value: 0 }, { name: this.$t('周二'), value: 0 }, { name: this.$t('周三'), value: 0 }, { name: this.$t('周四'), value: 0 }, { name: this.$t('周五'), value: 0 }, { name: this.$t('周六'), value: 0 }, ], }, ] }, getConfigOptions() { this.configTypeOptions = [] for (let i = 0; i < 31; i++) { const configTypeCode = (1026 + i).toString() this.configTypeOptions.push({ configTypeCode, disabled: false, configTypeName: this.$t('空开配置') + i, }) } }, // 处理配置类型变更 handleConfigTypeChange(value, index) { const selectConfigCodes = new Set(this.configArr.map(item => item.configTypeCode)) this.configTypeOptions.forEach(option => { option.disabled = selectConfigCodes.has(option.configTypeCode) }) if (value) { const selectedOption = this.configTypeOptions.find(opt => opt.configTypeCode == value) if (selectedOption) { this.configArr[index].configTypeName = selectedOption.configTypeName } } }, toggleDay(day, item) { day.value = day.value == 0 ? 1 : 0 const values = item.weekList.map(d => d.value) item.rept = values.join('') + '00' }, // 添加配置项 addConfig() { this.configArr.push({ configTypeCode: undefined, configTypeName: '', cmd: '', excTime: '', rept: '000000000', weekList: [ { name: this.$t('周日'), value: 0 }, { name: this.$t('周一'), value: 0 }, { name: this.$t('周二'), value: 0 }, { name: this.$t('周三'), value: 0 }, { name: this.$t('周四'), value: 0 }, { name: this.$t('周五'), value: 0 }, { name: this.$t('周六'), value: 0 }, ], }) }, // 删除配置项 delConfig(index) { if (this.configArr.length == 1) { this.$message.warning(this.$t('至少保留一个配置项')) } else { this.configArr.splice(index, 1) this.handleConfigTypeChange() } }, // 取消 cancel() { this.visible = false }, // 确定 submit() { this.$refs.ruleForm.validate(valid => { console.log(this.$refs.transferRef) if (!valid) return const detectorList = this.$refs.transferRef.rightData || [] if (detectorList.length === 0) { this.$message.destroy() this.$message.warning(this.$t('请选择设备列表')) return } let errMsg = '' // 检查所有配置项 for (let i = 0; i < this.configArr.length; i++) { const item = this.configArr[i] // 检查配置类型是否已选择 if (!item.configTypeCode) { errMsg = this.$t('请选择空开配置类型') break } // 检查操作类型 if (item.cmd === '' || item.cmd === null || item.cmd === undefined) { errMsg = `${this.$t('请选择')}${item.configTypeName}${this.$t('分合闸')}` break } // 检查时间 if (!item.excTime) { errMsg = `${this.$t('请选择')}${item.configTypeName}${this.$t('时间')}` break } // 检查周期 if (!item.rept || item.rept === '000000000') { errMsg = `${this.$t('请选择')}${item.configTypeName}${this.$t('周期')}` break } } if (errMsg) { this.$message.destroy() this.$message.warning(errMsg) return } // 准备参数 const configs = this.configArr.map(item => ({ configTypeCode: item.configTypeCode, configTypeName: item.configTypeName, configValue: { cid: (item.configTypeCode - 1026).toString(), cmd: item.cmd, excTime: item.excTime, time: moment().valueOf(), rept: item.rept, uid: '', type: '0', }, })) const params = { commandMode: '0', // 配置模式 主机0 探测器1 issueType: '1', // 1为首次下发 2为重新下发 jobName: this.modalData.taskName, userCode: localStorage.getItem('userId'), detectorList: detectorList.map(item => ({ ...item, channelNo: `${item.systemAddress}@${item.partUnitLoopCode}@${item.channelNo}`, })), configs, } console.log(params) factory.batchConfig(params).then(res => { if (res.success) { this.$message.destroy() this.$message.success('操作成功') this.handleCancel() this.$parent.getTableList() } }) }) }, }, } </script> <style lang="less" scoped> .addTaskModal { width: 100%; height: 100%; text-align: left; box-sizing: border-box; } .main-body-box { .config_content { border-radius: 4px; border: 1px solid #ebedef; .config_title { height: 48px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid rgb(229, 231, 234); background: rgb(242, 243, 244); justify-content: space-between; } .config_main { height: 176px; padding: 16px; display: flex; flex-direction: column; justify-content: space-around; align-items: flex-start; color: rgb(105, 118, 136); font-family: '阿里巴巴普惠体'; font-size: 14px; font-weight: 400; background: rgb(255, 255, 255); .type_info { display: flex; align-items: center; } .week_info { display: flex; align-items: center; .week_list { display: flex; .week_item { height: 40px; width: 82px; display: flex; cursor: default; align-items: center; justify-content: center; position: relative; border: 1px solid rgb(217, 220, 224); border-radius: 4px; margin-right: 12px; color: rgb(105, 118, 136); font-family: '阿里巴巴普惠体'; font-size: 14px; font-weight: 400; &.selected { color: #006fff; border: 1px solid rgb(0, 111, 255); } .triangle { position: absolute; bottom: 0; right: 0; width: 0; height: 0; border-style: solid; border-width: 0 0 24px 24px; border-color: transparent transparent #006fff transparent; } /* 对勾实现 */ .checkmark { position: absolute; bottom: 5px; /* 调整位置使其在三角形内居中 */ right: 4px; /* 调整位置使其在三角形内居中 */ width: 8px; height: 5px; transform: rotate(-45deg); &::before { content: ''; position: absolute; width: 2px; height: 5px; background-color: white; left: 0; top: 0; } &::after { content: ''; position: absolute; width: 6px; height: 2px; background-color: white; right: 0; bottom: 0; } } } } } span { margin-right: 8px; } } } .addBtn { width: 100%; height: 32px; cursor: default; display: flex; align-items: center; justify-content: center; border-radius: 4px; margin-top: 12px; color: rgb(41, 141, 255); border: 1px dashed rgb(41, 141, 255); background: rgba(41, 141, 255, 0.1); } } </style>代码评审
08-03
<template> <div class="taskDetail" v-show="visible"> <editAndAddPage :router="'/basicConfiguration'" eyeType :title="titles" @cancel="cancel" @submit="submit"> <template v-slot:topTitle> <span class="top_title base-flex-align"> <span class="icon_info"></span> <span class="title_info">{{ jobName }}</span> <span class="status_info base-flex-align" :class="{ green_color: taskStatus == 1, blue_color: taskStatus == 2, red_color: taskStatus == 3 }"> {{ taskStatusName[taskStatus].title }} </span> </span> </template> <template v-slot:pageBody> <div class="mian-content"> <div class="table-box"> <div class="title-info"><i></i>{{ $t('下发列表') }}</div> <a-table :columns="columns" :data-source="tableData" row-key="id" :scroll="{ x: '100%', y: 220 }" :pagination="false"> <template slot="operation" slot-scope="text, record"> <span :class="taskStatusName[record.detectorSendStatus].icon || ''" /> <a-tooltip placement="top"> <template slot="title"> <span>{{ record.weekInfo }}</span> </template> {{ taskStatusName[record.detectorSendStatus].title || "--" }} </a-tooltip> <hd-icon type="files" /> </template> </a-table> </div> <div class="pagination_box" v-show="tableData.length"> <my-pagination style="padding: 0 20px" :pageIndex.sync="pagination.currentPage" @changePage="changePage" :pageSize="pagination.pageSize" :total="pagination.totalRows" @onShowSizeChange="onShowSizeChange"></my-pagination> </div> <div class="config-box"> <div class="title-info"><i></i>{{ $t('空开配置') }}</div> <div class="config-list"> <div class="config-item" v-for="(item, index) in configDetail" :key="index"> <div class="config-title">{{ item.configTypeName }}</div> <div class="config-content"> <div> <span>{{ $t('配置内容:') }}</span> <span class="icon-item" :class="{ icon_gray: item.cmd == 0 }"></span> <span>{{ item.cmd == 0 ? $t('分闸') : $t('合闸') }}</span> </div> <div> <span>{{ $t('时间范围:') }}</span> <span>{{ item.executeTime }}</span> </div> <div class="week-item"> <span>{{ $t('运行周期:') }}</span> <span v-for="(el, indx) in item.weekList" :key="indx">{{ el }} </span> </div> </div> </div> </div> </div> </div> </template> </editAndAddPage> </div> </template> <script> import factory from '../factory' import myPagination from '@/components/scfComponents/paginationFormwork/myPagination.vue' import editAndAddPage from '@/components/scfComponents/editAndAddPage/editAndAddPage.vue' export default { components: { editAndAddPage, myPagination }, data() { return { titles: '空开定时任务详情', visible: false, columns: [ { title: '设备名称', dataIndex: 'deviceName', key: 'deviceName', ellipsis: true, }, { title: '操作结果', dataIndex: 'operation', key: 'operation', ellipsis: true, scopedSlots: { customRender: 'operation' }, }, { title: '探测器名称', dataIndex: 'detectorName', key: 'detectorName', ellipsis: true, }, { title: '探测器型号', dataIndex: 'productModel', key: 'productModel', ellipsis: true, }, { title: '探测器编号', dataIndex: 'detectorUniqueCode', key: 'detectorUniqueCode', ellipsis: true, }, { title: '所属组织', dataIndex: 'detectorOwnerName', key: 'detectorOwnerName', ellipsis: true, }, ], tableData: [], jobName: '', jobId: '', taskStatus: '', // 任务状态 taskStatusName: { 1: { title: this.$t('下发成功'), icon: 'hd-status-success' }, 2: { title: this.$t('下发中'), icon: 'hd-status-running' }, 3: { title: this.$t('下发失败'), icon: 'hd-status-error' }, 4: { title: this.$t('已清除'), icon: 'hd-status-error' }, }, configDetail: [], // 分页 pagination: { pageSize: 10, currentPage: 1, totalRows: 0, }, } }, methods: { // 打开弹窗 showModal(record) { this.visible = true this.jobName = record.jobName this.taskStatus = record.status this.jobId = record.jobId this.getDetailList() this.getDetectorJob() }, // 获取详情列表 getDetailList() { let params = { jobId: this.jobId, page: this.pagination.currentPage, pageSize: this.pagination.pageSize, } factory.getBatchjobDetailList(params).then(res => { if (res.success) { this.tableData = (res.data.pageData || []).map(item => ({ ...item, weekInfo: (item.configList || []) .filter(Boolean) .map(el => el.configTypeName || '') .join(','), })) console.log(this.tableData, 'this.tableData') this.pagination.totalRows = res.data.totalCount || 0 } }) }, // 查询已存在空开定时任务 getDetectorJob() { factory.getDetectorJob(this.jobId).then(res => { if (res.success) { this.configDetail = (res.data || []).map(item => { item.weekList = this.getActiveDays(item.rept) return item }) || [] } }) }, getActiveDays(rept) { const daysStr = rept.slice(0, 7).padEnd(7, '0') const activeDays = [] const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'] for (let i = 0; i < daysStr.length; i++) { if (daysStr[i] == '1') { activeDays.push(weekdays[i]) } } return activeDays }, // 失败重发 resendBatchjob() { factory.resendBatchjob(this.jobId).then(res => { if (res.success) { } }) }, // 取消 cancel() { this.visible = false }, }, } </script> <style lang="less" scoped> .taskDetail { .top_title { .icon_info { width: 1px; height: 16px; margin: 0 12px; display: inline-block; background: rgb(105, 118, 136); } .title_info { color: rgb(66, 75, 86); font-family: '微软雅黑'; font-size: 18px; font-weight: 400; } .status_info { margin-left: 12px; color: rgb(255, 255, 255); font-family: '阿里巴巴普惠体'; font-size: 14px; height: 24px; font-weight: 400; padding: 1px 12px; border-radius: 3px; &.green_color { background: rgb(39, 208, 90); } &.blue_color { background: rgb(41, 141, 255); } &.red_color { background: rgb(233, 70, 58); } } } .mian-content { width: 100%; height: 100%; position: relative; box-sizing: border-box; text-align: left; background-color: #eceef1; .title-info { display: flex; align-items: center; color: rgb(21, 23, 26); font-family: '阿里巴巴普惠体'; font-size: 16px; font-weight: 700; margin-bottom: 16px; i { width: 4px; height: 16px; display: inline-block; background: rgb(41, 141, 255); margin-right: 12px; } } .table-box, .config-box { width: 100%; padding: 20px; border-radius: 8px; box-sizing: border-box; background: rgb(255, 255, 255); } .config-box { margin-top: 16px; } .pagination_box { width: 100%; height: 64px; position: relative; background: #ffffff; } .config-list { .config-item { width: 33%; border: 1px solid #f2f3f4; .config-title { height: 46px; color: rgb(66, 75, 86); font-family: '阿里巴巴普惠体'; font-size: 14px; font-weight: 400; padding: 12px 16px 12px 16px; background: rgb(242, 243, 244); border-bottom: 1px solid rgb(229, 231, 234); } .config-content { height: 114px; padding: 16px; display: flex; flex-direction: column; justify-content: space-around; align-items: flex-start; > div > span:first-child { margin-right: 8px; } .icon-item { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: rgb(39, 208, 90); } .icon_gray { background: rgb(157, 166, 177); } } } } } } </style> 代码评审
最新发布
08-06
<template> <div class="addTaskModal" v-if="visible"> <editAndAddPage :router="'/basicConfiguration'" :title="titles" @cancel="cancel" @submit="submit"> <template v-slot:pageBody> <div class="main-body-box"> <a-form-model :label-col="{ span: 2 }" :wrapper-col="{ span: 22 }" ref="ruleForm" :rules="rules" :model="modalData" > <a-form-model-item label=""></a-form-model-item> <a-form-model-item :label="$t('任务名称:')" prop="taskName"> <a-input :placeholder="$t('请输入任务名称')" v-model="modalData.taskName" maxLength="25"> </a-input> </a-form-model-item> <a-form-model-item :label="$t('包含设备:')"> <Transfer ref="transferRef" :hostModel="modalData.hostModel"></Transfer> </a-form-model-item> <a-form-model-item :label="$t('空开配置:')"> <div class="config_content"> <div class="config_item" v-for="(item, index) in configArr" :key="index"> <div class="config_title"> <a-select v-model="item.configTypeCode" @change="value => handleConfigTypeChange(index, value)" :placeholder="$t('请选择')" > <a-select-option :value="el.configTypeCode" v-for="el in getAvailableOptions(index)" :key="el.configTypeCode" :title="$t(el.configTypeName)" > {{ $t(el.configTypeName) }} </a-select-option> </a-select> <hd-icon type="delete" @click="delConfig(index)" /> </div> <div class="config_main"> <div class="type_info"> <span>{{ $t('操作类型:') }}</span> <a-radio-group v-model="item.cmd" @change="onChange"> <a-radio-button value="0"> {{ $t('分闸') }}</a-radio-button> <a-radio-button value="1"> {{ $t('合闸') }} </a-radio-button> </a-radio-group> </div> <div class="time_info"> <span>{{ $t('时间范围:') }}</span> <a-time-picker class="mgb_12" format="HH:mm" valueFormat="HH:mm" v-model="item.excTime" :placeholder="$t('选择时间')" /> </div> <div class="week_info"> <span>{{ $t('运行周期:') }}</span> <div class="week_list"> <div class="week_item" v-for="(day, indx) in item.weekList" :key="indx" @click="toggleDay(day, item)" :class="{ selected: day.value == 1 }" > <div>{{ day.name }}</div> <div v-show="day.value == 1" class="triangle"></div> <div v-show="day.value == 1" class="checkmark"></div> </div> </div> </div> </div> </div> </div> <div class="addBtn" @click="addConfig"> <hd-icon type="add" /> {{ $t('新增空开配置') }} </div> </a-form-model-item> </a-form-model> </div> </template> </editAndAddPage> </div> </template> <script> import reg from '@/common/js/reg' import factory from '../factory' import Transfer from './Transfer.vue' import editAndAddPage from '@/components/scfComponents/editAndAddPage/editAndAddPage.vue' export default { components: { Transfer, editAndAddPage }, data() { return { titles: '新增空开定时任务', visible: false, modalData: { taskName: '', hostModel: undefined, }, rules: { taskName: [ { required: true, message: '请输入任务名称', trigger: 'blur' }, { pattern: reg.name, message: this.$t('仅允许输入汉字、字母、数字与_-.@字符') }, ], }, selectedConfigTypes: new Set(), // 存储已选的配置类型编码 configArr: [ { cmd: '', excTime: '', weekList: [ { name: '周日', value: 0 }, { name: '周一', value: 0 }, { name: '周二', value: 0 }, { name: '周三', value: 0 }, { name: '周四', value: 0 }, { name: '周五', value: 0 }, { name: '周六', value: 0 }, ], }, ], } }, computed: { allConfigOptions() { const arr = [] for (let i = 0; i < 31; i++) { const configTypeCode = (1026 + i).toString() arr.push({ configTypeCode, configTypeName: this.$t('空开配置') + i, }) } return arr }, }, mounted() {}, methods: { // 打开弹窗 showModal() { this.visible = true // 获取主机型号 this.modalData = { taskName: '', hostModel: undefined, } }, // 获取指定配置项可用的选项 getAvailableOptions(index) { const currentSelected = this.configArr[index].configTypeCode return this.allConfigOptions.filter(option => { // 当前项已选中的配置始终可用 if (option.configTypeCode === currentSelected) return true // 其他配置未被选中时可用 return !this.selectedConfigTypes.has(option.configTypeCode) }) }, // 处理配置类型变更 handleConfigTypeChange(index, value) { const prevValue = this.configArr[index].configTypeCode // 移除旧值 if (prevValue) { this.selectedConfigTypes.delete(prevValue) } // 添加新值 if (value) { this.selectedConfigTypes.add(value) } // 更新配置项的值 this.$set(this.configArr, index, { ...this.configArr[index], configTypeCode: value, }) }, toggleDay(day, item) { day.value = day.value == 0 ? 1 : 0 const values = item.weekList.map(day => day.value) item.configValue.rept = values.join('') + '00' }, // 添加配置项 addConfig() { this.configArr.push({ cmd: '', excTime: '', weekList: [ { name: '周日', value: 0 }, { name: '周一', value: 0 }, { name: '周二', value: 0 }, { name: '周三', value: 0 }, { name: '周四', value: 0 }, { name: '周五', value: 0 }, { name: '周六', value: 0 }, ], }) }, // 删除配置项 delConfig(index) { if (this.configArr.length == 1) { this.$message.destroy() this.$message.warning(this.$t('至少保留一个配置项')) } else { // 移除该配置项占用的类型 const removedConfig = this.configArr[index] if (removedConfig.configTypeCode) { this.selectedConfigTypes.delete(removedConfig.configTypeCode) } this.configArr.splice(index, 1) } }, // 取消 cancel() { this.visible = false }, // 确定 submit() { this.$refs.ruleForm.validate(valid => { if (!valid) return const detectorList = this.$refs.transferRef.getSelectedData() || [] if (detectorList.length === 0) { this.$message.destroy() this.$message.warning(this.$t('请选择设备列表')) return } let errMsg = '' let configs = this.configArr.filter(item => item.isCheck) if (configs.length === 0) { errMsg = this.$t('请选择配置定时开合闸') } else { for (let i = 0; i < configs.length; i++) { const { configValue, configTypeName, cmd, excTime } = configs[i] if (cmd == null || cmd === '' || (typeof cmd === 'string' && cmd.trim() === '')) { errMsg = `${this.$t('请选择')}${configTypeName}${this.$t('分合闸')}` break } else if (!excTime) { errMsg = `${this.$t('请选择')}${configTypeName}${this.$t('时间')}` break } else if (!configValue.rept || configValue.rept == '000000000') { errMsg = `${this.$t('请选择')}${configTypeName}${this.$t('周期')}` break } configValue.cmd = cmd configValue.excTime = moment(excTime, 'HH:mm').valueOf() configValue.time = moment().valueOf() } } if (errMsg) { this.$message.destroy() this.$message.warning(errMsg) return } let params = { commandMode: '0', // 配置模式 主机0 探测器1 issueType: '1', // 1为首次下发 2为重新下发 jobName: this.modalData.taskName, userCode: localStorage.getItem('userId'), detectorList: detectorList.map(item => ({ ...item, channelNo: `${item.systemAddress}@${item.partUnitLoopCode}@${item.channelNo}`, })), configs, } console.log(params) factory.batchConfig(params).then(res => { if (res.success) { this.$message.destroy() this.$message.success('操作成功') this.handleCancel() this.$parent.getTableList() } }) }) }, }, } </script> <style lang="less" scoped> .addTaskModal { width: 100%; height: 100%; text-align: left; box-sizing: border-box; } .main-body-box { .config_content { border-radius: 4px; border: 1px solid #ebedef; .config_title { height: 48px; display: flex; align-items: center; padding: 0 16px; border-bottom: 1px solid rgb(229, 231, 234); background: rgb(242, 243, 244); justify-content: space-between; } .config_main { height: 176px; padding: 16px; display: flex; flex-direction: column; justify-content: space-around; align-items: flex-start; color: rgb(105, 118, 136); font-family: '阿里巴巴普惠体'; font-size: 14px; font-weight: 400; background: rgb(255, 255, 255); .type_info { display: flex; align-items: center; } .week_info { display: flex; align-items: center; .week_list { display: flex; .week_item { height: 40px; width: 82px; display: flex; cursor: default; align-items: center; justify-content: center; position: relative; border: 1px solid rgb(217, 220, 224); border-radius: 4px; margin-right: 12px; color: rgb(105, 118, 136); font-family: '阿里巴巴普惠体'; font-size: 14px; font-weight: 400; &.selected { color: #006fff; border: 1px solid rgb(0, 111, 255); } .triangle { position: absolute; bottom: 0; right: 0; width: 0; height: 0; border-style: solid; border-width: 0 0 24px 24px; border-color: transparent transparent #006fff transparent; } /* 对勾实现 */ .checkmark { position: absolute; bottom: 5px; /* 调整位置使其在三角形内居中 */ right: 4px; /* 调整位置使其在三角形内居中 */ width: 8px; height: 5px; transform: rotate(-45deg); &::before { content: ''; position: absolute; width: 2px; height: 5px; background-color: white; left: 0; top: 0; } &::after { content: ''; position: absolute; width: 6px; height: 2px; background-color: white; right: 0; bottom: 0; } } } } } span { margin-right: 8px; } } } .addBtn { width: 100%; height: 32px; cursor: default; display: flex; align-items: center; justify-content: center; border-radius: 4px; margin-top: 12px; color: rgb(41, 141, 255); border: 1px dashed rgb(41, 141, 255); background: rgba(41, 141, 255, 0.1); } } </style> 代码评审
08-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值