chrislee пре 1 месец
родитељ
комит
8f2ffd6b40

+ 11 - 11
src/views/modules/common/user-component.vue

@@ -25,13 +25,13 @@ export default {
     event: 'userSelected'
   },
   watch: {
-    userId(value) {
+    userId (value) {
       this.value = value
       // 检查缺失item
       this.checkItem(value)
     }
   },
-  data() {
+  data () {
     return {
       value: '',
       current: 1,
@@ -42,20 +42,20 @@ export default {
       noMore: false
     }
   },
-  mounted() {
+  mounted () {
     this.init()
   },
   methods: {
-    async init() {
+    async init () {
       this.getList()
     },
-    remoteMethod(query) {
+    remoteMethod (query) {
       this.options = []
       this.current = 1
       this.name = query
       this.getList()
     },
-    getList() {
+    getList () {
       this.$http({
         url: this.$http.adornUrl(`/user-service/user/list`),
         method: 'get',
@@ -86,22 +86,22 @@ export default {
         }
       })
     },
-    handleClick() {
+    handleClick () {
       this.loadMore()
     },
-    loadMore() {
+    loadMore () {
       this.current++
       this.value = null
       this.getList()
     },
-    onChange(item) {
+    onChange (item) {
       if (item === 'undefined') {
         this.value = null
       }
       this.$emit('userSelected', item)
       this.$emit('userSelectedItem', { userId: item, userName: this.options.find(t => t.value === item).name })
     },
-    checkItem(code) {
+    checkItem (code) {
       if (!code || !this.options) return
       let i = this.options.findIndex(item => item.value === code)
       if (i > -1) return
@@ -121,7 +121,7 @@ export default {
         }
       })
     },
-    cancelReadOnly(onOff) {
+    cancelReadOnly (onOff) {
       this.$nextTick(() => {
         if (!onOff) {
           const input = this.$refs.select.$el.querySelector('.el-input__inner')

+ 148 - 0
src/views/modules/common/workshop-component.vue

@@ -0,0 +1,148 @@
+<template>
+  <el-select
+    v-model="value"
+    ref="select"
+    placeholder="请选择"
+    clearable
+    filterable
+    remote
+    :remote-method="remoteMethod"
+    @change = "onChange"
+    @focus="cancelReadOnly"
+    @hook:mounted="cancelReadOnly"
+    @visible-change="cancelReadOnly"
+    style="width: 200px">
+    <el-option
+      v-for="item in options"
+      :key="item.value"
+      :label="item.label"
+      :value="item.value">
+    </el-option>
+    <el-option v-if="options.length > 0" label="加载更多" style="font-style: italic; color: #8a979e" value="undefined" @click.native="handleClick()"></el-option>
+  </el-select>
+</template>
+
+<script>
+export default {
+  name: 'workshop-component',
+  props: {
+    workshopId: {
+      type: String,
+      default: ''
+    },
+    workshop: {
+      type: Object,
+      default: () => {}
+    }
+  },
+  model: {
+    prop: 'workshopId',
+    event: 'workshopSelected'
+  },
+  watch: {
+    workshopId (value) {
+      this.value = value
+      // 检查缺失item
+      this.checkItem(value)
+    }
+  },
+  data () {
+    return {
+      value: '',
+      current: 1,
+      size: 10,
+      name: '',
+      options: [],
+      loading: false,
+      noMore: false
+    }
+  },
+  mounted () {
+    this.init()
+  },
+  methods: {
+    async init () {
+      this.getList()
+    },
+    remoteMethod (query) {
+      this.options = []
+      this.current = 1
+      this.name = query
+      this.getList()
+    },
+    getList () {
+      this.$http({
+        url: this.$http.adornUrl(`/biz-service/pro-workshop/list`),
+        method: 'get',
+        params: this.$http.adornParams({
+          'current': this.current,
+          'size': this.size,
+          'name': this.name
+        })
+      }).then(({data}) => {
+        if (data && data.code === '200') {
+          if (this.current > data.data.pages) {
+            return
+          }
+          data.data.records.forEach(item => {
+            this.options.push({
+              label: item.name,
+              value: item.proWorkshopId
+            })
+          })
+        } else {
+          this.options = []
+        }
+      })
+    },
+    checkItem (id) {
+      if (!id || !this.options) return
+      let i = this.options.findIndex(item => item.value === id)
+      if (i > -1) return
+      // info
+      this.$http({
+        url: this.$http.adornUrl(`/biz-service/pro-workshop/info/${id}`),
+        method: 'get'
+      }).then(({ data }) => {
+        if (data && data.code === '200' && data.data) {
+          // 再次检查,防止异步重复添加
+          if (!this.options.some(opt => opt.value === data.data.userId)) {
+            this.options.push({
+              label: data.data.name,
+              value: data.data.proWorkshopId
+            })
+          }
+        }
+      })
+    },
+    handleClick () {
+      this.loadMore()
+    },
+    loadMore () {
+      this.current ++
+      this.getList()
+    },
+    onChange (item) {
+      if (item === 'undefined') {
+        this.value = null
+      }
+      this.$emit('workshopSelected', item)
+    },
+    cancelReadOnly (onOff) {
+      this.$nextTick(() => {
+        if (!onOff) {
+          const input = this.$refs.select.$el.querySelector('.el-input__inner')
+          const timer = setTimeout(() => {
+            input.removeAttribute('readonly')
+            clearTimeout(timer)
+          }, 200)
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

+ 15 - 9
src/views/modules/tech/work-type-add-or-update.vue

@@ -13,11 +13,18 @@
               <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
@@ -25,7 +32,7 @@
                 :disabled="display"
                 placeholder="请选择"
                 style="width:100%"
-                >
+              >
                 <el-option
                   v-for="item in optionsLevel"
                   :key="item.code"
@@ -35,12 +42,10 @@
               </el-select>
             </el-form-item>
           </el-col>
-        </el-row>
-        <el-row class="my-row">
-          <el-col :span="8">
+          <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> 
+                <i slot="suffix" style="font-style:normal;margin-right: 10px;">元</i>
               </el-input>
             </el-form-item>
           </el-col>
@@ -65,7 +70,7 @@
               <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">
+          <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>
@@ -81,13 +86,14 @@
 </template>
 
 <script>
-  import UserComponents from '../common/user-components'
-  import UserComponent from '../common/user-component'
+  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},
+    components: {UserComponents, UserComponent, WorkshopComponent},
     computed: {
       orgId: {
         get () { return this.$store.state.user.orgId }

+ 4 - 3
src/views/modules/tech/work-type-detail.vue

@@ -27,13 +27,14 @@
       </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="3">{{dataForm.quotedPrice}}元</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="3">{{dataForm.masterNames?dataForm.masterNames.toString():''}}</e-desc-item>
-        <e-desc-item label="负责人" span="3">{{dataForm.foremanName}}</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">

+ 8 - 9
src/views/modules/tech/workshop-add-or-update.vue

@@ -71,11 +71,11 @@ export default {
   components: {
     UserComponent
   },
-  data() {
+  data () {
     return {
       id: 0,
       dataForm: {
-        proWorkTypeList: [],
+        proWorkTypeList: []
       },
       materialList: [],
       dataRule: {
@@ -89,18 +89,18 @@ export default {
       }
     }
   },
-  created() {
+  created () {
   },
   methods: {
-    init(id) {
+    init (id) {
       this.id = id || 0
       if (!id) return
       this.getDetail()
     },
-    onChose() {
+    onChose () {
       this.$emit('onChose')
     },
-    getDetail() {
+    getDetail () {
       getDetail(this.id).then(({ data }) => {
         if (data && data.code === '200') {
           this.dataForm = data.data || {}
@@ -109,7 +109,7 @@ export default {
         }
       })
     },
-    dataFormSubmit() {
+    dataFormSubmit () {
       this.$refs['dataForm'].validate((valid) => {
         if (valid) {
           this.$http({
@@ -136,7 +136,7 @@ export default {
         }
       })
     },
-    removeWorkType(typeId, $index) {
+    removeWorkType (typeId, $index) {
       this.$confirm('确定要删除该工种记录吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -152,7 +152,6 @@ export default {
             this.$message.success('删除成功')
             // 删除这一行
             this.dataForm.proWorkTypeList.splice($index, 1)
-
           } else {
             this.$message.error(data && data.msg ? data.msg : '删除失败')
           }

+ 5 - 5
src/views/modules/tech/workshop-detail.vue

@@ -42,7 +42,7 @@ export default {
     EDesc,
     EDescItem
   },
-  data() {
+  data () {
     return {
       id: null,
       dataForm: {
@@ -57,15 +57,15 @@ export default {
     }
   },
   methods: {
-    onChose() {
+    onChose () {
       this.$emit('onChose')
     },
-    async init(id) {
+    async init (id) {
       if (!id) return
       this.id = id
       await this.getDetails()
     },
-    async getDetails() {
+    async getDetails () {
       try {
         const { data } = await getDetail(this.id)
         if (data && data.code === '200') {
@@ -88,4 +88,4 @@ export default {
   max-width: 700px;
   margin: 30px auto;
 }
-</style>
+</style>

+ 13 - 13
src/views/modules/tech/workshop-manage.vue

@@ -68,7 +68,7 @@ export default {
   components: {
     AddOrUpdate, Detail, AttachDetailDialog
   },
-  data() {
+  data () {
     return {
       addOrUpdateVisible: false,
       detailVisible: false,
@@ -82,21 +82,21 @@ export default {
       optionsLevel: []
     }
   },
-  created() {
+  created () {
     this.getDataList()
   },
   methods: {
-    onChose() {
+    onChose () {
       this.addOrUpdateVisible = false
       this.detailVisible = false
     },
     // 查询
-    queryData() {
+    queryData () {
       this.pageIndex = 1
       this.getDataList()
     },
     // 获取数据列表
-    getDataList() {
+    getDataList () {
       this.dataListLoading = true
       this.addOrUpdateVisible = false
       let params = {
@@ -116,39 +116,39 @@ export default {
       })
     },
     // 每页数
-    sizeChangeHandle(val) {
+    sizeChangeHandle (val) {
       this.pageSize = val
       this.pageIndex = 1
       this.getDataList()
     },
     // 当前页
-    currentChangeHandle(val) {
+    currentChangeHandle (val) {
       this.pageIndex = val
       this.getDataList()
     },
     // 多选
-    selectionChangeHandle(val) {
+    selectionChangeHandle (val) {
       this.dataListSelections = val
     },
     // 新增 / 修改
-    addOrUpdateHandle(id, disable) {
+    addOrUpdateHandle (id, disable) {
       this.addOrUpdateVisible = true
       this.$nextTick(() => {
         this.$refs.addOrUpdate.init(id, disable)
       })
     },
     // 详情
-    detailHandle(id) {
+    detailHandle (id) {
       this.detailVisible = true
       this.$nextTick(() => {
         this.$refs.detail.init(id)
       })
     },
-    attachDetails(attachList) {
+    attachDetails (attachList) {
       this.$refs.attachDetail.init(attachList)
     },
     // 删除
-    deleteHandle(id) {
+    deleteHandle (id) {
       this.$confirm('确定要删除该车间吗?', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -170,7 +170,7 @@ export default {
           this.dataListLoading = false
         })
       }).catch(() => { })
-    },
+    }
   }
 }
 </script>