小小儁爺
2024-08-01 bb2ed2e56da26a6b79575f5be9f60ca2d90774d0
src/views/basicSettings/processList.vue
@@ -229,7 +229,7 @@
    >
      <el-divider content-position="left">基本信息</el-divider>
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
      <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="110px">
        <el-form-item label="工序编码" prop="stepcode">
          <el-input v-model="dialogForm.stepcode" :disabled="operation!=='add'" style="width: 200px" />
        </el-form-item>
@@ -244,6 +244,7 @@
            :popper-append-to-body="false"
            @change="steptypecodeChange"
          >
            <el-option
              v-for="item in steptypeArr"
              :key="item.code"
@@ -253,9 +254,8 @@
          </el-select>
        </el-form-item>
        <el-form-item v-if="dialogForm.steptypecode==='Z'" label="所属车间" required>
        <el-form-item v-if="dialogForm.steptypecode==='Z'" label="所属车间">
          <el-select
            v-model="dialogForm.Wkshop"
            style="width:200px"
            placeholder="请选择"
@@ -269,6 +269,25 @@
              :key="item.torg_code"
              :label="item.torg_name"
              :value="item.torg_code"
            />
          </el-select>
        </el-form-item>
        <el-form-item v-if="dialogForm.steptypecode==='W'" label="往来单位类型">
          <el-select
            v-model="dialogForm.CustomerType"
            style="width:200px"
            placeholder="请选择"
            multiple
            collapse-tags
            :popper-append-to-body="false"
            @change="CustomerTypeChange"
          >
            <el-option
              v-for="item in CustomerTypeArr"
              :key="item.code"
              :label="item.name"
              :value="item.code"
            />
          </el-select>
        </el-form-item>
@@ -410,7 +429,13 @@
import elDragDialog from '@/directive/el-drag-dialog'
import waves from '@/directive/waves'
import $ from 'jquery'
import { CustomerPermissions, TorgWkshop, WkshopEqpPermissions } from '@/api/GeneralBasicData'
import {
  CustomerPermissions,
  CustomerTypePermissions,
  CustomerTypeSearchPermission,
  TorgWkshop,
  WkshopEqpPermissions
} from '@/api/GeneralBasicData'
export default {
  name: 'Zzjg',
@@ -427,8 +452,8 @@
        stepname: '', //
        enable: '', //
        steptypecode: '', // 工序类型
        prop: 'stepcode', // 排序字段
        order: 'asc', // 排序字段
        prop: 'lm_date', // 排序字段
        order: 'desc', // 排序字段
        page: 1, // 第几页
        rows: 20 // 每页多少条
      },
@@ -443,12 +468,14 @@
        { code: 'N', name: '停用' }
      ],
      WkshopArr: [], // 车间下拉数组
      CustomerTypeArr: [], // 往来单位下拉数组
      dialogVisible: false,
      dialogForm: {
        id: '',
        stepcode: '', //
        stepname: '', //
        Wkshop: '', //
        CustomerType: '', //
        steptypecode: 'Z',
        description: '', // 描述
        enable: 'Y'// 状态
@@ -486,6 +513,7 @@
  created() {
    this.getStepSearch()
    this.getTorgWkshop()
    this.getCustomerTypePermissions()
  },
  mounted() {
    window.addEventListener('resize', this.getHeight)
@@ -503,6 +531,11 @@
      const { data: res } = await TorgWkshop()
      this.WkshopArr = res
    },
    // 往来单位类型
    async getCustomerTypePermissions() {
      const { data: res } = await CustomerTypePermissions()
      this.CustomerTypeArr = res
    },
    // 查看往来资料
    async getCustomerPermissions() {
      const { data: res } = await CustomerPermissions()
@@ -515,21 +548,39 @@
    },
    async steptypecodeChange(val) {
      if (val === 'W') { // 外协
        await this.getCustomerPermissions()
      } else { // 自制
      // if (val === 'W') { // 外协
      //   this.dialogForm.CustomerType = []
      //   // await this.getCustomerPermissions()
      // } else { // 自制
      //   this.dialogForm.Wkshop = []
      // }
      this.dialogForm.CustomerType = []
        this.dialogForm.Wkshop = []
        this.dialogTreeArr = []
      }
    },
    // 车间值改变时触发
    async WkshopChange(val) {
      if (val.length === 0) {
        this.dialogTreeArr = []
        return
      }
      const { data: res } = await WkshopEqpPermissions({ wkshopcode: val.join(',') })
      this.dialogTreeArr = [
        { code: '',
          name: '全部',
          children: res
        }
      ]
    },
    // 往来单位类型值改变时
    async CustomerTypeChange(val) {
      if (val.length === 0) {
        this.dialogTreeArr = []
        return
      }
      const { data: res } = await CustomerTypeSearchPermission({ customertypecode: val.join(',') })
      this.dialogTreeArr = [
        { code: '',
          name: '全部',
@@ -585,14 +636,17 @@
        })
        await this.WkshopChange(this.dialogForm.Wkshop)
      } else if (row.flwtype === 'W') {
        await this.steptypecodeChange(row.flwtype)
        this.dialogForm.CustomerType = []
        // await this.steptypecodeChange(row.flwtype)
        res.filter(i => i.type === 'W' && i.flag === 'Y').forEach(i => {
          this.dialogForm.CustomerType.push(i.code)
          i.children.forEach(j => {
            if (j.flag === 'Y') {
              this.dialogTreeSelectedArr.push(j.code)
            }
          })
        })
        await this.CustomerTypeChange(this.dialogForm.CustomerType)
      }
      this.$nextTick(() => {
@@ -636,7 +690,7 @@
      this.dialogForm.steptypecode = 'Z'
      this.dialogTreeArr = []
      this.dialogForm.Wkshop = []
      this.dialogForm.CustomerType = []
      this.dialogTreeSelectedArr = []
      this.$refs.dialogForm.clearValidate()
    },