Browse Source

工种新增列和查询条件

chrislee 2 weeks ago
parent
commit
ebeb35f539

+ 172 - 169
src/views/modules/tech/work-type-add-or-update.vue

@@ -5,187 +5,190 @@
       width="70%"
       :close-on-click-modal="false"
       :visible.sync="visible"> -->
-      <div class="my-title">{{ !id ? '新增': display ? '详情' : '修改' }}</div>
-      <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
-        <el-row class="my-row">
-          <el-col :span="8">
-            <el-form-item label="工种编码" prop="code">
-              <el-input v-model="dataForm.code" :disabled="true" placeholder="系统自动生成"></el-input>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="车间" prop="proWorkshopId">
-              <WorkshopComponent v-model="dataForm.proWorkshopId" :workshop-id="dataForm.proWorkshopId" :disabled="display" style="width:100%;"/>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="工种名称" prop="name">
-              <el-input v-model="dataForm.name" :disabled="display" placeholder="工种名称"></el-input>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row class="my-row">
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="工种级别" prop="level">
-              <el-select
-                v-model="dataForm.level"
-                :disabled="display"
-                placeholder="请选择"
-                style="width:100%"
-              >
-                <el-option
-                  v-for="item in optionsLevel"
-                  :key="item.code"
-                  :label="item.value"
-                  :value="item.code">
-                </el-option>
-              </el-select>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="工时单价" prop="quotedPrice">
-              <el-input v-model="dataForm.quotedPrice" placeholder="工时单价" oninput="value=value.replace(/[^0-9.]/g,'')">
-                <i slot="suffix" style="font-style:normal;margin-right: 10px;">元</i>
-              </el-input>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row class="my-row">
-          <el-col :span="24">
-            <el-form-item label="工种要求" prop="requirement">
-              <el-input v-model="dataForm.requirement" :disabled="display" placeholder="工种要求"></el-input>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row class="my-row">
-          <el-col :span="24">
-            <el-form-item label="备注说明" prop="notes">
-              <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注说明"></el-input>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row class="my-row">
-          <el-col :span="8">
-            <el-form-item label="掌握人" prop="masterIds">
-              <user-components v-model="dataForm.masterIds" :user-ids="dataForm.masterIds" @change='masterChange' :disabled="display" style="width:100%;"/>
-            </el-form-item>
-          </el-col>
-          <el-col :span="8" style="padding-left: 20px">
-            <el-form-item label="负责人" prop="foreman">
-              <user-component v-model="dataForm.foreman" :user-id="dataForm.foreman" @userSelected='foremanChange' :disabled="display" style="width:100%;"/>
-            </el-form-item>
-          </el-col>
-        </el-row>
-      </el-form>
-      <span slot="footer" class="dialog-footer">
-          <el-button @click="onChose">取消</el-button>
-          <el-button v-if="!display" type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
-        </span>
+    <div class="my-title">{{ !id ? '新增' : display ? '详情' : '修改' }}</div>
+    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" label-width="auto">
+      <el-row class="my-row">
+        <el-col :span="8">
+          <el-form-item label="工种编码" prop="code">
+            <el-input v-model="dataForm.code" :disabled="true" placeholder="系统自动生成"></el-input>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="车间" prop="proWorkshopId">
+            <WorkshopComponent v-model="dataForm.proWorkshopId" :workshop-id="dataForm.proWorkshopId"
+              :disabled="display" style="width:100%;" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="工种名称" prop="name">
+            <el-input v-model="dataForm.name" :disabled="display" placeholder="工种名称"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="工种级别" prop="level">
+            <el-select v-model="dataForm.level" :disabled="display" placeholder="请选择" style="width:100%">
+              <el-option v-for="item in optionsLevel" :key="item.code" :label="item.value" :value="item.code">
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="工种类别" prop="typeName">
+            <el-select v-model="dataForm.typeName" :disabled="display" placeholder="请选择" style="width:100%">
+              <el-option label="生产" value="produce" />
+              <el-option label="检验" value="check" />
+              <el-option label="总检" value="t-check" />
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="工时单价" prop="quotedPrice">
+            <el-input v-model="dataForm.quotedPrice" placeholder="工时单价" oninput="value=value.replace(/[^0-9.]/g,'')">
+              <i slot="suffix" style="font-style:normal;margin-right: 10px;">元</i>
+            </el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="24">
+          <el-form-item label="工种要求" prop="requirement">
+            <el-input v-model="dataForm.requirement" :disabled="display" placeholder="工种要求"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="24">
+          <el-form-item label="备注说明" prop="notes">
+            <el-input v-model="dataForm.notes" :disabled="display" placeholder="备注说明"></el-input>
+          </el-form-item>
+        </el-col>
+      </el-row>
+      <el-row class="my-row">
+        <el-col :span="8">
+          <el-form-item label="掌握人" prop="masterIds">
+            <user-components v-model="dataForm.masterIds" :user-ids="dataForm.masterIds" @change='masterChange'
+              :disabled="display" style="width:100%;" />
+          </el-form-item>
+        </el-col>
+        <el-col :span="8" style="padding-left: 20px">
+          <el-form-item label="负责人" prop="foreman">
+            <user-component v-model="dataForm.foreman" :user-id="dataForm.foreman" @userSelected='foremanChange'
+              :disabled="display" style="width:100%;" />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="onChose">取消</el-button>
+      <el-button v-if="!display" type="primary" @click="dataFormSubmit()" v-reClick>确定</el-button>
+    </span>
     <!-- </el-dialog> -->
   </div>
 </template>
 
 <script>
-  import UserComponents from '@/views/modules/common/user-components'
-  import UserComponent from '@/views/modules/common/user-component'
-  import WorkshopComponent from '@/views/modules/common/workshop-component.vue'
-  import { getDictList } from '@/api/dict'
-  import { addOrUpdateWorkType, getWorkTypeDetail } from '@/api/product'
-  export default {
-    name: 'work-type-add-or-update',
-    components: {UserComponents, UserComponent, WorkshopComponent},
-    computed: {
-      orgId: {
-        get () { return this.$store.state.user.orgId }
+import UserComponents from '@/views/modules/common/user-components'
+import UserComponent from '@/views/modules/common/user-component'
+import WorkshopComponent from '@/views/modules/common/workshop-component.vue'
+import { getDictList } from '@/api/dict'
+import { addOrUpdateWorkType, getWorkTypeDetail } from '@/api/product'
+export default {
+  name: 'work-type-add-or-update',
+  components: { UserComponents, UserComponent, WorkshopComponent },
+  computed: {
+    orgId: {
+      get() { return this.$store.state.user.orgId }
+    }
+  },
+  data() {
+    return {
+      visible: false,
+      display: false,
+      optionsLevel: [],
+      id: 0,
+      dataForm: {},
+      dataRule: {
+        name: [{ required: true, message: '工种名称不能为空', trigger: 'blur' }],
+        level: [{ required: true, message: '工种级别不能为空', trigger: 'change' }],
+        typeName: [{ required: true, message: '工种类别不能为空', trigger: 'change' }],
+        requirement: [{ required: true, message: '工种要求不能为空', trigger: 'blur' }],
+        quotedPrice: [{ required: true, message: '工时单价不能为空', trigger: 'blur' }],
+        masterIds: [{ required: true, message: '请选择掌握人', trigger: 'blur' }],
+        foreman: [{ required: true, message: '请选择工种负责人', trigger: 'blur' }]
       }
+    }
+  },
+  methods: {
+    onChose() {
+      this.$emit('onChose')
     },
-    data () {
-      return {
-        visible: false,
-        display: false,
-        optionsLevel: [],
-        id: 0,
-        dataForm: {},
-        dataRule: {
-          name: [{ required: true, message: '工种名称不能为空', trigger: 'blur' }],
-          level: [{ required: true, message: '工种级别不能为空', trigger: 'change' }],
-          requirement: [{ required: true, message: '工种要求不能为空', trigger: 'blur' }],
-          quotedPrice: [{ required: true, message: '工时单价不能为空', trigger: 'blur' }],
-          masterIds: [{ required: true, message: '请选择掌握人', trigger: 'blur' }],
-          foreman: [{ required: true, message: '请选择工种负责人', trigger: 'blur' }]
+    async init(id, display) {
+      this.dataForm = {}
+      this.optionsLevel = []
+      this.visible = true
+      this.id = id || 0
+      this.display = display
+      // 获取工种级别
+      await getDictList({ type: 'pro_work_level' }).then(({ data }) => {
+        if (data) {
+          this.optionsLevel = data
         }
-      }
+      })
+      if (!id) return
+      await getWorkTypeDetail(this.id).then(({ data }) => {
+        if (data && data.code === '200') {
+          this.dataForm = data.data
+        }
+      })
     },
-    methods: {
-      onChose () {
-        this.$emit('onChose')
-      },
-      async init (id, display) {
-        this.dataForm = {}
-        this.optionsLevel = []
-        this.visible = true
-        this.id = id || 0
-        this.display = display
-        // 获取工种级别
-        await getDictList({type: 'pro_work_level'}).then(({data}) => {
-          if (data) {
-            this.optionsLevel = data
-          }
-        })
-        if (!id) return
-        await getWorkTypeDetail(this.id).then(({data}) => {
-          if (data && data.code === '200') {
-            this.dataForm = data.data
+    validateField(type) {
+      this.$refs.dataForm.validateField(type)
+    },
+    // 表单提交
+    dataFormSubmit() {
+      this.$refs['dataForm'].validate((valid) => {
+        if (valid) {
+          let params = {
+            level: this.dataForm.level,
+            masterIds: this.dataForm.masterIds,
+            name: this.dataForm.name,
+            notes: this.dataForm.notes,
+            orgId: this.orgId,
+            requirement: this.dataForm.requirement,
+            quotedPrice: this.dataForm.quotedPrice,
+            typeId: this.id ? this.id : null,
+            foreman: this.dataForm.foreman,
+            typeName: this.dataForm.typeName,
+            proWorkshopId: this.dataForm.proWorkshopId
           }
-        })
-      },
-      validateField (type) {
-        this.$refs.dataForm.validateField(type)
-      },
-      // 表单提交
-      dataFormSubmit () {
-        this.$refs['dataForm'].validate((valid) => {
-          if (valid) {
-            let params = {
-              level: this.dataForm.level,
-              masterIds: this.dataForm.masterIds,
-              name: this.dataForm.name,
-              notes: this.dataForm.notes,
-              orgId: this.orgId,
-              requirement: this.dataForm.requirement,
-              quotedPrice: this.dataForm.quotedPrice,
-              typeId: this.id ? this.id : null,
-              foreman: this.dataForm.foreman,
-              proWorkshopId: this.dataForm.proWorkshopId
+          addOrUpdateWorkType(params, !this.id).then(({ data }) => {
+            if (data && data.code === '200') {
+              this.$message({
+                message: '操作成功',
+                type: 'success',
+                duration: 1500,
+                onClose: () => {
+                  this.onChose()
+                  this.$emit('refreshDataList')
+                }
+              })
+            } else {
+              this.$message.error(data.msg)
             }
-            addOrUpdateWorkType(params, !this.id).then(({data}) => {
-              if (data && data.code === '200') {
-                this.$message({
-                  message: '操作成功',
-                  type: 'success',
-                  duration: 1500,
-                  onClose: () => {
-                    this.onChose()
-                    this.$emit('refreshDataList')
-                  }
-                })
-              } else {
-                this.$message.error(data.msg)
-              }
-            }).catch(() => {})
-          }
-        })
-      },
-      masterChange (val) {
-        this.dataForm.masterIds = val
-      },
-      foremanChange (val) {
-        this.dataForm.foreman = val
-      }
+          }).catch(() => { })
+        }
+      })
+    },
+    masterChange(val) {
+      this.dataForm.masterIds = val
+    },
+    foremanChange(val) {
+      this.dataForm.foreman = val
     }
   }
+}
 </script>
 
-<style scoped>
-
-</style>
+<style scoped></style>

+ 71 - 62
src/views/modules/tech/work-type-detail.vue

@@ -10,31 +10,32 @@
       <!-- 工作流 -->
       <div v-show="dataForm.workFlowBusinessExt">
         <el-steps :active="activeNo" finish-status="success" align-center style="margin-bottom: 20px">
-          <template v-for="(item, i) in stepList">
-            <el-step :key="i + '_mesg'" :icon="item.icon" :title="item.title" :description="item.description"></el-step>
-          </template>
+          <el-step v-for="(item, i) in stepList" :key="i + '_mesg'" :icon="item.icon" :title="item.title"
+            :description="item.description" />
         </el-steps>
         <el-collapse style="margin-bottom: 20px">
           <el-collapse-item>
             <template slot="title">
               <span style="color: red">审批日志(展开查看更多):</span>
             </template>
-            <template v-for="(item, i) in logList">
-              <div :key="i + '_log'">{{++i}}:{{item.approverName}}  {{item.createTime}}  {{item.approvalValue}}</div>
-            </template>
+            <div v-for="(item, i) in logList" :key="i + '_log'">
+              {{ i + 1 }}:{{ item.approverName }} {{ item.createTime }} {{ item.approvalValue }}
+            </div>
           </el-collapse-item>
         </el-collapse>
       </div>
       <e-desc title="基本信息" column="3">
-        <e-desc-item label="工种编码">{{dataForm.code}}</e-desc-item>
-        <e-desc-item label="车间">{{dataForm.proWorkshopName}}</e-desc-item>
-        <e-desc-item label="工种名称">{{dataForm.name}}</e-desc-item>
-        <e-desc-item label="工种级别">{{dataForm.levelValue}}</e-desc-item>
-        <e-desc-item label="工时单价" span="2">{{dataForm.quotedPrice}}元</e-desc-item>
-        <e-desc-item label="工种要求" span="3">{{dataForm.requirement}}</e-desc-item>
-        <e-desc-item label="备注" span="3">{{dataForm.notes}}</e-desc-item>
-        <e-desc-item label="掌握人" span="1">{{dataForm.masterNames?dataForm.masterNames.toString():''}}</e-desc-item>
-        <e-desc-item label="负责人" span="2">{{dataForm.foremanName}}</e-desc-item>
+        <e-desc-item label="工种编码">{{ dataForm.code }}</e-desc-item>
+        <e-desc-item label="车间">{{ dataForm.proWorkshopName }}</e-desc-item>
+        <e-desc-item label="工种名称">{{ dataForm.name }}</e-desc-item>
+        <e-desc-item label="工种级别">{{ dataForm.levelValue }}</e-desc-item>
+        <e-desc-item label="工种类别">{{ formatType(dataForm) }}</e-desc-item>
+        <e-desc-item label="工时单价">{{ dataForm.quotedPrice }}元</e-desc-item>
+        <e-desc-item label="工种要求" span="3">{{ dataForm.requirement }}</e-desc-item>
+        <e-desc-item label="备注" span="3">{{ dataForm.notes }}</e-desc-item>
+        <e-desc-item label="掌握人" span="1">{{ dataForm.masterNames ? dataForm.masterNames.toString() : ''
+        }}</e-desc-item>
+        <e-desc-item label="负责人" span="2">{{ dataForm.foremanName }}</e-desc-item>
       </e-desc>
     </div>
     <span slot="footer" class="dialog-footer">
@@ -45,63 +46,71 @@
 </template>
 
 <script>
-  import EDesc from '../common/e-desc'
-  import EDescItem from '../common/e-desc-item'
-  import { dealStepData, dealStepLogs } from '@/api/util'
-  import uploadComponent from '../common/upload-component'
-  import { getWorkTypeDetail } from '@/api/product'
-  export default {
-    name: 'work-type-detail',
-    components: {
-      EDesc, EDescItem, uploadComponent
+import EDesc from '../common/e-desc'
+import EDescItem from '../common/e-desc-item'
+import { dealStepData, dealStepLogs } from '@/api/util'
+import uploadComponent from '../common/upload-component'
+import { getWorkTypeDetail } from '@/api/product'
+export default {
+  name: 'work-type-detail',
+  components: {
+    EDesc, EDescItem, uploadComponent
+  },
+  data() {
+    return {
+      visible: false,
+      id: 0,
+      dataForm: {},
+      activeNo: 0,
+      stepList: [],
+      logList: []
+    }
+  },
+  methods: {
+    onChose() {
+      this.$emit('onChose')
+    },
+    // 转换属性“工种类别”
+    formatType(row) {
+      const val = row.type || row.typeName
+      const map = { 'produce': '生产', 'check': '检验', 't-check': '总检' }
+      if (!val) return ''
+      return map[val] || (Object.values(map).includes(val) ? val : '')
     },
-    data () {
-      return {
-        visible: false,
-        id: 0,
-        dataForm: {},
-        activeNo: 0,
-        stepList: [],
-        logList: []
-      }
+    async init(id) {
+      this.visible = true
+      this.id = id || 0
+      this.dataForm = {}
+      this.stepList = []
+      this.logList = []
+      this.getDetails()
     },
-    methods: {
-      onChose () {
-        this.$emit('onChose')
-      },
-      async init (id) {
-        this.visible = true
-        this.id = id || 0
-        this.dataForm = {}
-        this.stepList = []
-        this.logList = []
-        this.getDetails()
-      },
-      getDetails () {
-        getWorkTypeDetail(this.id).then(({data}) => {
-          if (data && data.code === '200') {
-            this.dataForm = data.data
-            // 流程图展示
-            if (data.data.workFlowBusinessExt) {
-              dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
-              dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
-            }
-            if (data.data.workFlowProcessStepList) {
-              this.activeNo = Number(data.data.workFlowProcessStepList.activeNo)
-            }
+    getDetails() {
+      getWorkTypeDetail(this.id).then(({ data }) => {
+        if (data && data.code === '200') {
+          this.dataForm = data.data
+          // 流程图展示
+          if (data.data.workFlowBusinessExt) {
+            dealStepData(data.data.workFlowBusinessExt.workFlowProcessStepList, this.stepList)
+            dealStepLogs(data.data.workFlowBusinessExt.processLogList, this.logList)
           }
-        })
-      }
+          if (data.data.workFlowProcessStepList) {
+            this.activeNo = Number(data.data.workFlowProcessStepList.activeNo)
+          }
+        }
+      })
     }
   }
+}
 </script>
 
 <style scoped>
-.my-line{
+.my-line {
   border-bottom: 1px solid #c0c4cc;
   margin-bottom: 10px;
 }
-.title{
-  padding: 10px 0 ;
+
+.title {
+  padding: 10px 0;
 }
 </style>

+ 17 - 2
src/views/modules/tech/work-type.vue

@@ -12,6 +12,9 @@
             </el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="车间">
+          <workshop-component v-model="dataForm.proWorkshopId" />
+        </el-form-item>
         <el-form-item>
           <el-button @click="queryData()">查询</el-button>
           <el-button v-if="isAuth('pro:worktype:save')" type="primary"
@@ -32,6 +35,8 @@
         </el-table-column>
         <el-table-column prop="level" header-align="center" align="center" :formatter="formatLevel" label="工种级别">
         </el-table-column>
+        <el-table-column header-align="center" align="center" label="工种类别" :formatter="formatType">
+        </el-table-column>
         <el-table-column prop="requirement" header-align="center" align="center" min-width="120"
           :show-tooltip-when-overflow="true" label="工种要求">
         </el-table-column>
@@ -76,10 +81,11 @@ import AddOrUpdate from './work-type-add-or-update'
 import Detail from './work-type-detail'
 import { getDictList } from '@/api/dict'
 import { getWorkTypeList } from '@/api/product'
+import WorkshopComponent from '@/views/modules/common/workshop-component'
 export default {
   name: 'work-type',
   components: {
-    AddOrUpdate, Detail
+    AddOrUpdate, Detail, WorkshopComponent
   },
   data() {
     return {
@@ -125,7 +131,8 @@ export default {
         'current': this.pageIndex,
         'size': this.pageSize,
         'name': this.dataForm.name ? this.dataForm.name : null,
-        'level': this.dataForm.level ? this.dataForm.level : null
+        'level': this.dataForm.level ? this.dataForm.level : null,
+        'proWorkshopId': this.dataForm.proWorkshopId ? this.dataForm.proWorkshopId : null
       }
       getWorkTypeList(params).then(({ data }) => {
         if (data && data.code === '200') {
@@ -167,6 +174,14 @@ export default {
         return item1 ? item1.value : ''
       }
     },
+    // 转换属性“工种类别”
+    formatType(row) {
+      const val = row.type || row.typeName
+      const map = { 'produce': '生产', 'check': '检验', 't-check': '总检' }
+      if (!val) return ''
+      // 若后端已返回中文,直接显示;否则按编码映射
+      return map[val] || (Object.values(map).includes(val) ? val : '')
+    },
     // 转换属性“掌握人”
     formatNames(row) {
       if (row.masterNames && row.masterNames.length > 0) {