ysy 2 лет назад
Родитель
Сommit
de7831477f

+ 8 - 5
src/views/technology/production/components/user-edit.vue

@@ -33,10 +33,9 @@
         <el-col :span="8">
           <el-form-item label="工序类型:" prop="type">
             <el-select v-model="form.type" filterable>
-              <el-option key="1" label="普通工序" :value="1"> </el-option>
-              <el-option key="2" label="抽样质检" :value="2"> </el-option>
-              <el-option key="3" label="普通质检" :value="3"> </el-option>
-              <el-option key="4" label="包装工序" :value="4"> </el-option>
+              <el-option :label="item.label" :value="item.value" v-for="(item, index) in typeList " :key="index">
+              </el-option>
+
             </el-select>
           </el-form-item>
         </el-col>
@@ -198,7 +197,8 @@ export default {
     visible: Boolean,
     // 修改回显的数据
     data: Object,
-    controlList: Array
+    controlList: Array,
+    typeList: Array
   },
   data() {
 
@@ -258,6 +258,9 @@ export default {
         { code: 2, label: '最短时间' }
       ],
 
+
+
+
       // 表单验证规则
       rules: {
         name: [

+ 198 - 206
src/views/technology/production/index.vue

@@ -2,74 +2,40 @@
   <div class="ele-body">
     <el-card shadow="never">
       <!-- 搜索表单 -->
-      <user-search @search="reload"  />
+      <user-search @search="reload" />
       <!-- 数据表格 -->
-      <ele-pro-table
-        ref="table"
-        :columns="columns"
-        :datasource="datasource"
-        :selection.sync="selection"
-        row-key="id"
-      >
+      <ele-pro-table ref="table" :columns="columns" :datasource="datasource" :selection.sync="selection" row-key="id">
         <!-- 表头工具栏 -->
-      <template v-slot:toolbar>
-          <el-button
-            size="small"
-            type="primary"
-            icon="el-icon-plus"
-            class="ele-btn-icon"
-            @click="openEdit()"
-          >
+        <template v-slot:toolbar>
+          <el-button size="small" type="primary" icon="el-icon-plus" class="ele-btn-icon" @click="openEdit()">
             新建
           </el-button>
-          <el-button
-            size="small"
-            type="danger"
-            icon="el-icon-delete"
-            class="ele-btn-icon"
-            @click="removeBatch"
-          >
+          <el-button size="small" type="danger" icon="el-icon-delete" class="ele-btn-icon" @click="removeBatch">
             删除
           </el-button>
-        </template> 
+        </template>
 
         <template v-slot:roleList="{ row }">
-          <el-tag
-            v-for="item in row.roleList"
-            :key="item.id"
-            size="mini"
-            type="primary"
-            :disable-transitions="true"
-          >
+          <el-tag v-for="item in row.roleList" :key="item.id" size="mini" type="primary" :disable-transitions="true">
             {{ item.name }}
           </el-tag>
         </template>
         <!-- 状态列 -->
 
+        <template v-slot:type="{ row }">
+          {{ typeLabel(row.type) }}
+        </template>
+
         <!-- 操作列 -->
         <template v-slot:action="{ row }">
-        <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-edit"
-            @click="openEdit(row)"
-          >
+          <el-link type="primary" :underline="false" icon="el-icon-edit" @click="openEdit(row)">
             修改
-          </el-link> 
-          <el-link
-            type="primary"
-            :underline="false"
-            icon="el-icon-setting"
-            @click="openSetting(row)"
-          >
+          </el-link>
+          <el-link type="primary" :underline="false" icon="el-icon-setting" @click="openSetting(row)">
             配置工艺参数
           </el-link>
 
-         <el-popconfirm
-            class="ele-action"
-            title="确定要删除当前工序吗?"
-            @confirm="remove(row)"
-          >
+          <el-popconfirm class="ele-action" title="确定要删除当前工序吗?" @confirm="remove(row)">
             <template v-slot:reference>
               <el-link type="danger" :underline="false" icon="el-icon-delete">
                 删除
@@ -80,177 +46,203 @@
       </ele-pro-table>
     </el-card>
     <!-- 编辑弹窗 -->
-    <user-edit
-      :visible.sync="showEdit"
-      :data="current"
-      :controlList="controlList"
-      @done="reload"
-      ref="userEdit"
-    />
+    <user-edit :visible.sync="showEdit" :data="current" :controlList="controlList" @done="reload" ref="userEdit"
+      :typeList="typeList" />
     <!-- 配置工艺参数 -->
-    <user-setting
-      :visible.sync="showSetting"
-      :data="current"
-      ref="userSetting"
-    />
+    <user-setting :visible.sync="showSetting" :data="current" ref="userSetting" />
   </div>
 </template>
 
 <script>
-  import UserSearch from './components/user-search.vue';
-  import UserEdit from './components/user-edit.vue';
-  import UserSetting from './components/user-setting.vue';
-  import producetask from '@/api/technology/production';
-  import control from '@/api/technology/control';
-  export default {
-    name: 'technologyProduction',
-    components: {
-      UserSearch,
-      UserEdit,
-      UserSetting
+import UserSearch from './components/user-search.vue';
+import UserEdit from './components/user-edit.vue';
+import UserSetting from './components/user-setting.vue';
+import producetask from '@/api/technology/production';
+import control from '@/api/technology/control';
+export default {
+  name: 'technologyProduction',
+  components: {
+    UserSearch,
+    UserEdit,
+    UserSetting
+  },
+  data() {
+    return {
+      // 表格列配置
+      columns: [
+        {
+          columnKey: 'selection',
+          type: 'selection',
+          width: 45,
+          align: 'center',
+          fixed: 'left'
+        },
+        {
+          prop: 'code',
+          label: '工序编码',
+          // sortable: 'custom',
+          showOverflowTooltip: true,
+          align: 'center',
+          minWidth: 110
+        },
+        {
+          prop: 'name',
+          label: '工序名称',
+          showOverflowTooltip: true,
+          align: 'center',
+          minWidth: 110
+        },
+
+        {
+          slot: 'type',
+          label: '工序类型',
+          showOverflowTooltip: true,
+          align: 'center',
+          minWidth: 110
+        },
+        {
+          align: 'center',
+          prop: 'controlName',
+          label: '工序控制码',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+        {
+          prop: 'workCenterName',
+          label: '所属工作中心',
+          align: 'center',
+          showOverflowTooltip: true,
+          minWidth: 110
+        },
+
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 260,
+          align: 'center',
+          resizable: false,
+          slot: 'action',
+          showOverflowTooltip: true
+        }
+      ],
+      // 表格选中数据
+      selection: [],
+      // 当前编辑数据
+      current: null,
+      // 是否显示编辑弹窗
+      showEdit: false,
+      // 是否显示参数弹窗
+      showSetting: false,
+      controlList: [],
+
+
+      typeList: [
+        {
+          value: 1,
+          label: '普通工序'
+        },
+        {
+          value: 2,
+          label: '抽样质检'
+        }, {
+          value: 3,
+          label: '普通质检'
+        }, {
+          value: 4,
+          label: '包装工序'
+        },
+        {
+          value: 5,
+          label: '常规质检'
+        },
+      ],
+    };
+  },
+  methods: {
+
+    typeLabel(type) {
+       return this.typeList.find(m =>m.value == type) && this.typeList.find(m =>m.value == type).label
     },
-    data() {
-      return {
-        // 表格列配置
-        columns: [
-          {
-            columnKey: 'selection',
-            type: 'selection',
-            width: 45,
-            align: 'center',
-            fixed: 'left'
-          },
-          {
-            prop: 'code',
-            label: '工序编码',
-            // sortable: 'custom',
-            showOverflowTooltip: true,
-            align: 'center',
-            minWidth: 110
-          },
-          {
-            prop: 'name',
-            label: '工序名称',
-            showOverflowTooltip: true,
-            align: 'center',
-            minWidth: 110
-          },
-          {
-            align: 'center',
-            prop: 'controlName',
-            label: '工序控制码',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
-          {
-            prop: 'workCenterName',
-            label: '所属工作中心',
-            align: 'center',
-            showOverflowTooltip: true,
-            minWidth: 110
-          },
 
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 260,
-            align: 'center',
-            resizable: false,
-            slot: 'action',
-            showOverflowTooltip: true
-          }
-        ],
-        // 表格选中数据
-        selection: [],
-        // 当前编辑数据
-        current: null,
-        // 是否显示编辑弹窗
-        showEdit: false,
-        // 是否显示参数弹窗
-        showSetting: false,
-        controlList:[]
-      };
+    /*配置工艺参数 */
+    openSetting(row) {
+      this.current = row;
+      this.showSetting = true;
+    },
+    /* 表格数据源 */
+    async datasource({ page, limit, where, order }) {
+      const res = await producetask.list({
+        ...where,
+        ...order,
+        pageNum: page,
+        size: limit
+      });
+      return res;
     },
-    methods: {
-      /*配置工艺参数 */
-      openSetting(row) {
-        this.current = row;
-        this.showSetting = true;
-      },
-      /* 表格数据源 */
-      async datasource({ page, limit, where, order }) {
-        const res = await producetask.list({
-          ...where,
-          ...order,
-          pageNum: page,
-          size: limit
-        });
-        return res;
-      },
 
-      /* 刷新表格 */
-      reload(where) {
-        this.$refs.table.reload({ page: 1, where: where });
-      },
-      /* 打开编辑弹窗 */
-      openEdit(row) {
-        this.getControlList()
-        this.current = row;
-        this.showEdit = true;
-        this.$refs.userEdit.$refs.form &&
+    /* 刷新表格 */
+    reload(where) {
+      this.$refs.table.reload({ page: 1, where: where });
+    },
+    /* 打开编辑弹窗 */
+    openEdit(row) {
+      this.getControlList()
+      this.current = row;
+      this.showEdit = true;
+      this.$refs.userEdit.$refs.form &&
         this.$refs.userEdit.$refs.form.clearValidate();
-      },
+    },
 
-      getControlList(){
-         const params = {
-           pageNum: 1, size: -1
-         }
-         control.list().then(res=>{
-            this.controlList = res.list
-         })
-      },
+    getControlList() {
+      const params = {
+        pageNum: 1, size: -1
+      }
+      control.list().then(res => {
+        this.controlList = res.list
+      })
+    },
 
-      /* 删除 */
-      remove(row) {
-        const loading = this.$loading({ lock: true });
+    /* 删除 */
+    remove(row) {
+      const loading = this.$loading({ lock: true });
 
-        producetask
-          .delete([row.id])
-          .then((msg) => {
-            loading.close();
-            this.$message.success('删除' + msg);
-            this.reload();
-          })
-          .catch((e) => {
-            loading.close();
-            // this.$message.error(e.message);
-          });
-      },
-      /* 批量删除 */
-      removeBatch() {
-        if (!this.selection.length) {
-          this.$message.error('请至少选择一条数据');
-          return;
-        }
-        this.$confirm('确定要删除选中的工序吗?', '提示', {
-          type: 'warning'
+      producetask
+        .delete([row.id])
+        .then((msg) => {
+          loading.close();
+          this.$message.success('删除' + msg);
+          this.reload();
         })
-          .then(() => {
-            const loading = this.$loading({ lock: true });
-            producetask
-              .delete(this.selection.map((d) => d.id))
-              .then((msg) => {
-                loading.close();
-                this.$message.success('删除' + msg);
-                this.reload();
-              })
-              .catch((e) => {
-                loading.close();
-                // this.$message.error(e.message);
-              });
-          })
-          .catch(() => {});
+        .catch((e) => {
+          loading.close();
+          // this.$message.error(e.message);
+        });
+    },
+    /* 批量删除 */
+    removeBatch() {
+      if (!this.selection.length) {
+        this.$message.error('请至少选择一条数据');
+        return;
       }
+      this.$confirm('确定要删除选中的工序吗?', '提示', {
+        type: 'warning'
+      })
+        .then(() => {
+          const loading = this.$loading({ lock: true });
+          producetask
+            .delete(this.selection.map((d) => d.id))
+            .then((msg) => {
+              loading.close();
+              this.$message.success('删除' + msg);
+              this.reload();
+            })
+            .catch((e) => {
+              loading.close();
+              // this.$message.error(e.message);
+            });
+        })
+        .catch(() => { });
     }
-  };
+  }
+};
 </script>