Procházet zdrojové kódy

终端工单模板优化

NULL1222 před 2 týdny
rodič
revize
edbc53e1c7

+ 18 - 5
src/Form/terminalWorkBillModule/add.vue

@@ -20,7 +20,7 @@
                 >
                     <el-col :span="24">
                         <el-form-item :label="$t('模板名称:')" prop="name">
-                            <el-input v-model="form.name" :placeholder="$t('请填写')"></el-input>
+                            <el-input ref="nameInput" v-model="form.name" :placeholder="$t('请填写')"></el-input>
                         </el-form-item>
                     </el-col>
                     <el-col :span="24">
@@ -118,6 +118,9 @@ export default {
                 this.form = Object.assign({}, this.form, this.data);
                 this.form.type = this.data.type ? this.data.type.split('/') : [];
             }
+            this.$nextTick(() => {
+                this.$refs.nameInput.focus();
+            });
         },
         onSubmit() {
             console.log(this.form);
@@ -130,10 +133,20 @@ export default {
                     content: this.form,
                 });
                 this.tool.showMessage(res, () => {
-                    this.$emit('onSuccess');
-                    this.loading = false;
-                    this.$refs['form'].resetFields();
-                    this.dialogFormVisible = false;
+                    setTimeout(() => {
+                        this.loading = false;
+                        this.$emit('onSuccess');
+                        this.$refs['form'].resetFields();
+                        this.dialogFormVisible = false;
+                        this.$store.dispatch('changeDetailDrawer', true);
+                        this.$router.push({
+                            path: '/terminalWorkBillModuleDetail',
+                            query: {
+                                id: res.data.sc_workorder_templateid,
+                                rowindex: res.data.rowindex,
+                            },
+                        });
+                    }, 500);
                 });
             });
         },

+ 37 - 11
src/HDrpManagement/terminalWorkBillModule/index.vue

@@ -18,19 +18,13 @@
                     {{ scope.data.column.data.ispoints == 1 ? $t('是') : $t('否') }}
                 </div>
                 <div v-else-if="scope.data.column.columnname == 'isused'">
-                    <!-- <el-switch
-                        v-model="scope.data.column.data.isused"
-                        active-color="#67C23A"
-                        inactive-color="#999999"
-                        @change="switchChnage(scope.data.column.data.isused)"
-                    >
-                    </el-switch> -->
                     <el-switch
-                        disabled
                         :active-value="1"
                         :inactive-value="0"
-                        v-model="scope.data.column.data.isused"
+                        :value="scope.data.column.data.isused"
                         size="small"
+                        :loading="switchLoadingId === scope.data.column.data.sc_workorder_templateid"
+                        @change="switchChange(scope.data.column.data, $event)"
                     ></el-switch>
                 </div>
                 <div v-else>
@@ -49,10 +43,42 @@
 <script>
 export default {
     data() {
-        return {};
+        return {
+            switchLoadingId: null,
+        };
     },
     methods: {
-        // switchChnage(val) {},
+        switchChange(data, newVal) {
+            const actionText = newVal == 1 ? '启用' : '禁用';
+            this.$confirm(this.$t(`确认${actionText}当前工单模板吗`) + '?', this.$t('提示'), {
+                confirmButtonText: this.$t('确定'),
+                cancelButtonText: this.$t('取消'),
+                type: 'warning',
+                beforeClose: async (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        this.switchLoadingId = data.sc_workorder_templateid;
+                        const res = await this.$api.requested({
+                            id: '2026051513140102',
+                            content: {
+                                sc_workorder_templateid: data.sc_workorder_templateid,
+                                isused: newVal,
+                            },
+                        });
+                        this.tool.showMessage(res, () => {
+                            setTimeout(() => {
+                                instance.confirmButtonLoading = false;
+                                this.switchLoadingId = null;
+                                done();
+                                this.$refs.list.listData();
+                            }, 500);
+                        });
+                    } else {
+                        done();
+                    }
+                },
+            }).catch(() => {});
+        },
         detailGo(row) {
             let route = this.$route;
             if (route.path !== '/terminalWorkBillModuleDetail') {

+ 42 - 21
src/HDrpManagement/terminalWorkBillModule/modules/detail.vue

@@ -23,29 +23,21 @@
                     :data="mainData"
                     @onSuccess="queryMainData"
                 ></Edit>
-                <customBtn
-                    :btnName="$t('启 用')"
-                    :message="$t('确认启用当前工单模板吗') + '?'"
-                    idName="2026051513140102"
-                    keyName="sc_workorder_templateid"
-                    :id="$route.query.id"
-                    @onSuccess="queryMainData"
-                    class="inline-16"
-                    :paramData="[{ key: 'isused', value: 1 }]"
+                <el-button
                     v-if="mainData.isused == 0"
-                />
-                <customBtn
-                    :btnName="$t('禁 用')"
-                    :message="$t('确认禁用当前工单模板吗') + '?'"
-                    idName="2026051513140102"
-                    keyName="sc_workorder_templateid"
-                    :id="$route.query.id"
-                    @onSuccess="queryMainData"
-                    class="inline-16"
-                    :paramData="[{ key: 'isused', value: 0 }]"
+                    type="primary"
+                    size="mini"
+                    :loading="btnLoading"
+                    @click="onToggleUsed(1, '启用')"
+                >{{ $t('启 用') }}</el-button>
+                <el-button
                     v-if="mainData.isused == 1"
-                />
-                <el-button type="primary" @click="onDelete" size="mini">{{ $t(`删 除`) }}</el-button>
+                    type="warning"
+                    size="mini"
+                    :loading="btnLoading"
+                    @click="onToggleUsed(0, '禁用')"
+                >{{ $t('禁 用') }}</el-button>
+                <el-button type="danger" @click="onDelete" size="mini">{{ $t(`删 除`) }}</el-button>
             </template>
             <div slot="slot0">
                 <taskDetail> </taskDetail>
@@ -69,6 +61,7 @@ export default {
             mainAreaData: [],
             detailInfo: '',
             processDetailList: [],
+            btnLoading: false,
         };
     },
     components: { Edit, BaseInfo, taskDetail },
@@ -78,6 +71,34 @@ export default {
         };
     },
     methods: {
+        onToggleUsed(value, actionText) {
+            this.$confirm(this.$t(`确认${actionText}当前工单模板吗`) + '?', this.$t('提示'), {
+                confirmButtonText: this.$t('确定'),
+                cancelButtonText: this.$t('取消'),
+                type: 'warning',
+                beforeClose: async (action, instance, done) => {
+                    if (action === 'confirm') {
+                        instance.confirmButtonLoading = true;
+                        const res = await this.$api.requested({
+                            id: '2026051513140102',
+                            content: {
+                                sc_workorder_templateid: this.$route.query.id,
+                                isused: value,
+                            },
+                        });
+                        this.tool.showMessage(res, () => {
+                            setTimeout(() => {
+                                instance.confirmButtonLoading = false;
+                                done();
+                                this.queryMainData();
+                            }, 500);
+                        });
+                    } else {
+                        done();
+                    }
+                },
+            }).catch(() => {});
+        },
         onDelete() {
             this.$confirm(this.$t('是否确认删除此工单模板') + '?', this.$t('提示'), {
                 confirmButtonText: this.$t('确定'),