ysy 1 year ago
parent
commit
f9dd307f1e

+ 157 - 0
src/views/inspectionClassify/components/qualityItem.vue

@@ -0,0 +1,157 @@
+<template>
+  <el-dialog
+    :title="title"
+    v-if="visible"
+    :visible.sync="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="false"
+    :close-on-press-escape="false"
+    append-to-body
+    width="70%"
+  >
+    <el-card shadow="never">
+      <userEditSearch @search="reload" />
+
+      <!-- 数据表格 -->
+      <ele-pro-table
+        ref="table"
+        :columns="columns"
+        :datasource="datasource"
+        :selection.sync="selection"
+        row-key="id"
+      >
+      </ele-pro-table>
+    </el-card>
+
+    <div class="btns">
+      <el-button type="primary" size="small" @click="selected">选择</el-button>
+      <el-button size="small" @click="handleClose">关闭</el-button>
+    </div>
+  </el-dialog>
+</template>
+
+<script>
+  import { getList } from '@/api/inspectionStandard';
+  import userEditSearch from './user-edit-search.vue';
+
+  export default {
+    components: {
+      userEditSearch
+    },
+    mixins: [],
+
+    data() {
+      return {
+        visible: false,
+        title: '选择质检项',
+
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'selection',
+            type: 'selection',
+            width: 45,
+            align: 'center',
+            selectable: (row, index) => {
+              return !this.processData.some((it) => it.id == row.id);
+            },
+            reserveSelection: true,
+            fixed: 'left'
+          },
+          {
+            prop: 'code',
+            label: '质检编码'
+          },
+          {
+            label: '质检名称',
+            prop: 'name'
+          },
+
+          {
+            label: '状态',
+            prop: 'status',
+            slot: 'status'
+          },
+
+          {
+            label: '版本号',
+            prop: 'version'
+          },
+
+          {
+            label: '标准类型',
+            prop: 'type',
+            slot: 'type'
+          },
+
+          {
+            label: '标准代码',
+            prop: 'standardCode'
+          }
+        ],
+
+        // 表格选中数据
+        selection: [],
+
+        processData: [],
+        categoryId: null
+      };
+    },
+
+    watch: {},
+    methods: {
+      open() {
+        this.visible = true;
+      },
+
+      /* 表格数据源 */
+      async datasource({ page, limit, where }) {
+        const res = await getList({
+          ...where,
+          categoryLevelId: this.categoryId,
+          pageNum: page,
+          size: limit
+        });
+        return res;
+      },
+
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({ page: 1, where: where });
+      },
+
+      handleClose() {
+        this.visible = false;
+        this.$refs.table.setSelectedRows([]);
+        this.selection = [];
+      },
+      selected() {
+        if (!this.selection.length) {
+          this.$message.error('请至少选择一条数据');
+          return;
+        }
+        let _arr = [];
+        _arr = this.selection.map((m) => {
+          return {
+            qualityStandardId: m.id,
+            status: 1,
+            mode: null,
+            version: null,
+            categoryLevelId: this.categoryId,
+            rootCategoryLevelId: '12'
+          };
+        });
+
+        this.$emit('chooseProcess', _arr);
+        this.handleClose();
+      }
+    }
+  };
+</script>
+
+<style lang="scss" scoped>
+  .btns {
+    text-align: center;
+    padding: 10px 0;
+  }
+</style>

+ 167 - 153
src/views/inspectionClassify/components/user-list.vue

@@ -20,7 +20,7 @@
           class="ele-btn-icon"
           @click="openAdd()"
         >
-          新增
+          添加质检项
         </el-button>
       </template>
       <!-- 编码列 -->
@@ -35,20 +35,29 @@
           :underline="false"
           @click="openDetail(row.qualityStandard)"
         >
-          {{row.qualityStandard && row.qualityStandard.code }}
+          {{ row.qualityStandard && row.qualityStandard.code }}
         </el-link>
       </template>
 
       <template v-slot:type="{ row }">
-        {{ getDictValue('质检标准类型',  row.qualityStandard && row.qualityStandard.type) }}
+        {{
+          getDictValue(
+            '质检标准类型',
+            row.qualityStandard && row.qualityStandard.type
+          )
+        }}
       </template>
 
       <template v-slot:standardCode="{ row }">
-        {{row.qualityStandard &&  row.qualityStandard.standardCode }}
+        {{ row.qualityStandard && row.qualityStandard.standardCode }}
       </template>
 
       <template v-slot:status="{ row }">
-        {{ row.qualityStandard && row.qualityStandard.status == 1 ? '启用' : '停用' }}
+        {{
+          row.qualityStandard && row.qualityStandard.status == 1
+            ? '启用'
+            : '停用'
+        }}
       </template>
 
       <template v-slot:mode="{ row }">
@@ -82,168 +91,173 @@
       </template>
     </ele-pro-table>
 
-    <Add @chooseProcess="chooseProcess" ref="addRef" />
+    <!-- <Add @chooseProcess="chooseProcess" ref="addRef" /> -->
 
     <edit ref="edit" @done="done"></edit>
     <Detail ref="detailRef"></Detail>
-    
-
+    <qualityItem ref="qualityItemRef"></qualityItem>
   </div>
 </template>
 
 <script>
-import userSearch from './user-search.vue';
-import { getList, removeItem, saveBatch } from '@/api/inspectionClassify/index';
-import dictMixins from '@/mixins/dictMixins';
-import Add from './add.vue';
-import Edit from './edit.vue';
-import Detail from '@/views/inspectionStandard/components/edit.vue';
-
-export default {
-  mixins: [dictMixins],
-  components: { userSearch, Add, Edit ,Detail},
-  props: {
-    // 类别id
-
-    rootId: [Number, String]
-  },
-  data() {
-    return {
-      // 当前编辑数据
-      current: null,
-
-      // 表格列配置
-      columns: [
-        {
-          columnKey: 'index',
-          type: 'index',
-          label: '序号',
-          width: 55,
-          align: 'center'
-        },
-
-        {
-          prop: 'code',
-          label: '标准编码',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          slot: 'code'
-        },
-
-        {
-          prop: 'name',
-          label: '标准名称',
-          showOverflowTooltip: true,
-          minWidth: 110,
-          slot: 'name'
-        },
-
-        {
-          label: '标准类型',
-          prop: 'type',
-          slot: 'type'
-        },
-
-        {
-          label: '标准代码',
-          prop: 'standardCode'
-        },
-
-        {
-          prop: 'status',
-          label: '状态',
-          align: 'center',
-          minWidth: 110,
-          slot: 'status'
-        },
-
-        {
-          prop: 'version',
-          label: '版本号',
-          align: 'center',
-          minWidth: 110,
-          slot: 'version'
-        },
-
-        {
-          label: '操作',
-          prop: 'action',
-          slot: 'action',
-          action: 'action'
-        }
-      ]
-    };
-  },
-  created() {
-    this.requestDict('质检方式');
-    this.requestDict('质检标准类型');
-  },
-  methods: {
-    /* 表格数据源 */
-    datasource({ page, limit, where }) {
-      return getList({
-        ...where,
-        pageNum: page,
-        size: limit,
-        categoryLevelId: this.categoryLevelId || 12,
-        rootCategoryLevelId: this.rootId
-      });
-    },
-    /* 刷新表格 */
-    reload(where) {
-      this.$refs.table.reload({
-        pageNum: 1,
-        where: where,
-        categoryLevelId: this.categoryLevelId,
-        rootCategoryLevelId: this.rootId
-      });
-    },
+  import userSearch from './user-search.vue';
+  import {
+    getList,
+    removeItem,
+    saveBatch
+  } from '@/api/inspectionClassify/index';
+  import dictMixins from '@/mixins/dictMixins';
+  // import Add from './add.vue';
+  import Edit from './edit.vue';
+  import Detail from '@/views/inspectionStandard/components/edit.vue';
+  import qualityItem from './qualityItem.vue'
 
-    /* 打开编辑弹窗 */
-    openAdd() {
-      this.$refs.addRef.open(this.categoryLevelId || 12);
-    },
+  export default {
+    mixins: [dictMixins],
+    components: { userSearch, Edit, Detail , qualityItem},
+    props: {
+      // 类别id
 
-    openEdit(row) {
-      this.$refs.edit.open(row);
+      rootId: [Number, String]
     },
-    openDetail(row) {
-      console.log(row)
-      this.$refs.detailRef.open('detail',row);
+    data() {
+      return {
+        // 当前编辑数据
+        current: null,
+
+        // 表格列配置
+        columns: [
+          {
+            columnKey: 'index',
+            type: 'index',
+            label: '序号',
+            width: 55,
+            align: 'center'
+          },
+
+          {
+            prop: 'code',
+            label: '标准编码',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'code'
+          },
+
+          {
+            prop: 'name',
+            label: '标准名称',
+            showOverflowTooltip: true,
+            minWidth: 110,
+            slot: 'name'
+          },
+
+          {
+            label: '标准类型',
+            prop: 'type',
+            slot: 'type'
+          },
+
+          {
+            label: '标准代码',
+            prop: 'standardCode'
+          },
+
+          {
+            prop: 'status',
+            label: '状态',
+            align: 'center',
+            minWidth: 110,
+            slot: 'status'
+          },
+
+          {
+            prop: 'version',
+            label: '版本号',
+            align: 'center',
+            minWidth: 110,
+            slot: 'version'
+          },
+
+          {
+            label: '操作',
+            prop: 'action',
+            slot: 'action',
+            action: 'action'
+          }
+        ]
+      };
     },
-    
-    chooseProcess(data) {
-      saveBatch(data).then((res) => {
-        console.log(res);
-        if (res.code == 0) {
-          this.$message.success(res.message);
-          this.reload();
-        }
-      });
+    created() {
+      this.requestDict('质检方式');
+      this.requestDict('质检标准类型');
     },
+    methods: {
+      /* 表格数据源 */
+      datasource({ page, limit, where }) {
+        return getList({
+          ...where,
+          pageNum: page,
+          size: limit,
+          categoryLevelId: this.categoryLevelId || 12,
+          rootCategoryLevelId: this.rootId
+        });
+      },
+      /* 刷新表格 */
+      reload(where) {
+        this.$refs.table.reload({
+          pageNum: 1,
+          where: where,
+          categoryLevelId: this.categoryLevelId,
+          rootCategoryLevelId: this.rootId
+        });
+      },
+
+      /* 打开编辑弹窗 */
+      openAdd() {
+        // this.$refs.addRef.open(this.categoryLevelId || 12);
+        this.$refs.qualityItemRef.open()
+      },
 
-    /* 删除 */
-    remove(row) {
-      const loading = this.$loading({ lock: true });
-      removeItem([row.id])
-        .then((msg) => {
-          loading.close();
-          this.$message.success(msg);
-          this.reload();
-        })
-        .catch((e) => {
-          loading.close();
+      openEdit(row) {
+        this.$refs.edit.open(row);
+      },
+      openDetail(row) {
+        console.log(row);
+        this.$refs.detailRef.open('detail', row);
+      },
+
+      chooseProcess(data) {
+        saveBatch(data).then((res) => {
+          console.log(res);
+          if (res.code == 0) {
+            this.$message.success(res.message);
+            this.reload();
+          }
         });
-    },
-    done() {
-      this.$refs.searchRef.search();
-    },
+      },
+
+      /* 删除 */
+      remove(row) {
+        const loading = this.$loading({ lock: true });
+        removeItem([row.id])
+          .then((msg) => {
+            loading.close();
+            this.$message.success(msg);
+            this.reload();
+          })
+          .catch((e) => {
+            loading.close();
+          });
+      },
+      done() {
+        this.$refs.searchRef.search();
+      },
 
-    clickSearch(info) {
-      this.categoryLevelId = info.id;
-      this.rootCategoryLevelId = info.rootCategoryLevelId;
-      this.reload();
+      clickSearch(info) {
+        this.categoryLevelId = info.id;
+        this.rootCategoryLevelId = info.rootCategoryLevelId;
+        this.reload();
+      }
     }
-  }
-};
+  };
 </script>

+ 49 - 7
src/views/inspectionProject/components/user-edit.vue

@@ -12,6 +12,24 @@
     <header-title title="基本信息"></header-title>
     <el-form ref="form" :model="form" :rules="rules" label-width="120px">
       <el-row>
+        <el-col :span="12">
+          <el-form-item label="质检标准:" prop="qualityStandardId">
+            <el-select
+              v-model="form.qualityStandardId"
+              placeholder="请选择"
+              class="ele-block"
+              filterable
+            >
+              <el-option
+                :label="item.name"
+                v-for="item in qualityStandardList"
+                :key="item.id"
+                :value="item.id"
+              />
+            </el-select>
+          </el-form-item>
+        </el-col>
+
         <el-col :span="12">
           <el-form-item label="参数编码:" prop="inspectionCode">
             <el-input
@@ -118,7 +136,7 @@
           </el-form-item>
         </el-col>
 
-        <el-col :span="12">
+        <el-col :span="24">
           <el-form-item label="工艺要求:" prop="inspectionStandard">
             <el-input v-model="form.inspectionStandard">
               <DictSelection
@@ -154,11 +172,15 @@
           </el-form-item>
         </el-col>
 
-        <el-col :span="20">
-          <el-form-item label="备注:">
+        <el-col :span="12">
+          <el-form-item label="备注:" prop="inspectionRemark">
             <el-input placeholder="请输入" v-model="form.inspectionRemark" />
           </el-form-item>
         </el-col>
+
+        <el-col :span="12">
+          <el-form-item label="附件:" prop="imgUrl"> </el-form-item>
+        </el-col>
       </el-row>
     </el-form>
 
@@ -174,6 +196,8 @@
 <script>
   import { save, update, getById } from '@/api/inspectionProject';
 
+  import { getList } from '@/api/inspectionStandard';
+
   export default {
     props: {
       // 弹窗是否打开
@@ -184,6 +208,7 @@
     data() {
       const defaultForm = {
         id: null,
+        qualityStandardId: '',
         inspectionCode: '',
         inspectionName: '',
         textType: '1',
@@ -194,11 +219,11 @@
         minValue: '',
         unitName: '',
 
- 
         inspectionStandard: '',
         unit: '',
         symbol: '',
         inspectionRemark: '',
+        imgUrl: []
       };
       return {
         defaultForm,
@@ -221,9 +246,13 @@
           { code: 2, label: '最短时间' }
         ],
 
+        qualityStandardList: [],
         // 表单验证规则
         rules: {
-          name: [
+          qualityStandardId: [
+            { required: true, message: '请选择质检标准', trigger: 'blur' }
+          ],
+          inspectionName: [
             { required: true, message: '请输入质检名称', trigger: 'blur' }
           ],
           inspectionCode: [
@@ -266,6 +295,10 @@
         return this.$store.state.theme.styleResponsive;
       }
     },
+
+    created() {
+      this.getListFn();
+    },
     methods: {
       /* 保存编辑 */
       save() {
@@ -320,6 +353,17 @@
       /* 更新visible */
       updateVisible(value) {
         this.$emit('update:visible', value);
+      },
+
+      getListFn() {
+        let param = {
+          pageNum: 1,
+          size: -1
+        };
+
+        getList(param).then((res) => {
+          this.qualityStandardList = res.list;
+        });
       }
     },
 
@@ -328,7 +372,6 @@
         if (visible) {
           if (this.data) {
             const res = await getById(this.data.id);
-            console.log(666, res);
 
             this.$util.assignObject(this.form, {
               ...res
@@ -339,7 +382,6 @@
           }
         } else {
           this.$refs.form.clearValidate();
-          this.$refs.form1.clearValidate();
 
           this.form = { ...this.defaultForm };
         }

+ 53 - 10
src/views/inspectionProject/components/user-search.vue

@@ -7,29 +7,56 @@
     @submit.native.prevent
   >
     <el-row>
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 4 }">
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4 }">
         <el-form-item label="参数编码:">
           <el-input clearable v-model.trim="where.code" placeholder="请输入" />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 4 }">
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4 }">
         <el-form-item label="参数名称:">
           <el-input clearable v-model.trim="where.name" placeholder="请输入" />
         </el-form-item>
       </el-col>
-      <el-col v-bind="styleResponsive ? { lg: 5, md: 12 } : { span: 4 }">
-        <el-form-item label="参数默认值:">
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4 }">
+        <el-form-item label="工艺要求:">
           <el-input
             clearable
-            v-model.trim="where.defaultValue"
+            v-model.trim="where.inspectionStandard"
             placeholder="请输入"
           />
         </el-form-item>
       </el-col>
 
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4 }">
+        <el-form-item label="标准类型:" prop="type">
+          <DictSelection
+            dictName="质检标准类型"
+            v-model="where.type"
+          ></DictSelection>
+        </el-form-item>
+      </el-col>
+
+      <el-col v-bind="styleResponsive ? { lg: 4, md: 10 } : { span: 4 }">
+        <el-form-item label="质检标准:">
+          <el-select
+            v-model="where.qualityStandardId"
+            placeholder="请选择"
+            style="width: 100%"
+            clearable
+            filterable
+          >
+            <el-option
+              :label="item.name"
+              v-for="item in qualityStandardList"
+              :key="item.id"
+              :value="item.id"
+            />
+          </el-select>
+        </el-form-item>
+      </el-col>
 
-      <el-col v-bind="styleResponsive ? { lg: 4, md: 12 } : { span: 4 }">
-        <div class="ele-form-actions">
+      <el-col v-bind="styleResponsive ? { lg: 3, md: 8 } : { span: 4 }">
+        <div class="ele-form-actions" style="margin-left: 8px">
           <el-button
             type="primary"
             icon="el-icon-search"
@@ -46,19 +73,20 @@
 </template>
 
 <script>
+  import { getList } from '@/api/inspectionStandard';
   export default {
     data() {
       // 默认表单数据
       const defaultWhere = {
         code: '',
         name: '',
-        defaultValue: '',
-        categoryType: ''
+        inspectionStandard: '',
+        qualityStandardId: ''
       };
       return {
         // 表单数据
         where: { ...defaultWhere },
-   
+        qualityStandardList: []
       };
     },
     computed: {
@@ -67,6 +95,9 @@
         return this.$store.state.theme.styleResponsive;
       }
     },
+    created() {
+      this.getListFn();
+    },
     methods: {
       /* 搜索 */
       search() {
@@ -76,6 +107,18 @@
       reset() {
         this.where = { ...this.defaultWhere };
         this.search();
+      },
+
+      getListFn() {
+        let param = {
+          pageNum: 1,
+          size: -1
+        };
+
+        getList(param).then((res) => {
+          this.qualityStandardList = res.list;
+
+        });
       }
     }
   };