liding
11 小时以前 6f2e5c16bdefdf7129809ae303aa5e66b74cd2f7
feat(order): 添加检验委托单关联功能
已修改4个文件
542 ■■■■ 文件已修改
package.json 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/cnas/process/demand/demand.js 28 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/CNAS/process/demand/index.vue 350 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/business/productOrder/components/addOrder.vue 160 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json
@@ -49,14 +49,16 @@
    "echarts": "5.4.0",
    "element-resize-detector": "^1.2.4",
    "element-ui": "2.15.14",
    "fast-png": "^5.0.0",
    "file-saver": "2.0.5",
    "fuse.js": "6.4.3",
    "highlight.js": "9.18.5",
    "html2canvas": "^1.4.1",
    "iobuffer": "^5.0.0",
    "js-beautify": "1.13.0",
    "js-cookie": "3.0.1",
    "jsencrypt": "3.0.0-rc.1",
    "jspdf": "^3.0.0",
    "jspdf": "^2.5.0",
    "mammoth": "^1.9.0",
    "moment": "^2.30.1",
    "nprogress": "0.2.0",
src/api/cnas/process/demand/demand.js
@@ -13,10 +13,10 @@
    params: query
  })
}
// 委托单查询成品订单
export function getInsOrderOnInspection(query) {
// 查询未绑定检验委托单(供成品下单选择)
export function pageUnboundInspectionOrder(query) {
  return request({
    url: '/inspectionOrder/getInsOrderOnInspection',
    url: '/inspectionOrder/pageUnboundInspectionOrder',
    method: 'get',
    params: query
  })
@@ -37,14 +37,30 @@
    data: query
  })
}
// 新增时根据成品订单查询委托单详情
export function getInspectionOrderByInsOderId(query) {
// 根据检验委托单获取成品下单初始化信息
export function getInspectionOrderForPlaceOrder(query) {
  return request({
    url: '/inspectionOrder/getInspectionOrderByInsOderId',
    url: '/inspectionOrder/getInspectionOrderForPlaceOrder',
    method: 'get',
    params: query
  })
}
// 新增成品下单并绑定检验委托单
export function addInsOrderWithInspectionOrder(query) {
  return request({
    url: '/inspectionOrder/addInsOrderWithInspectionOrder',
    method: 'post',
    data: query
  })
}
// 变更检验委托单关联
export function changeInspectionOrderBinding(query) {
  return request({
    url: '/inspectionOrder/changeBinding',
    method: 'post',
    params: query
  })
}
// 委托单检验查看详情
export function getInspectionOrderOne(query) {
  return request({
src/views/CNAS/process/demand/index.vue
@@ -2,6 +2,10 @@
  <div class="app-container">
    <div style="display: flex;justify-content: space-between;">
      <el-form :model="entitySearch" ref="entitySearch" size="small" :inline="true">
        <el-form-item label="委托单号" prop="inspectionOrderCode">
          <el-input size="small" placeholder="请输入" clearable v-model="entitySearch.inspectionOrderCode"
            @keyup.enter.native="refreshTable"></el-input>
        </el-form-item>
        <el-form-item label="试样名称" prop="sampleName">
          <el-input size="small" placeholder="请输入" clearable v-model="entitySearch.sampleName"
            @keyup.enter.native="refreshTable"></el-input>
@@ -31,8 +35,26 @@
      <el-table v-loading="tableListLoading" :data="tableList"
                height="630" border :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }">
        <el-table-column align="center" label="序号" type="index"></el-table-column>
        <el-table-column label="委托单号" prop="inspectionOrderCode" min-width="160" show-overflow-tooltip></el-table-column>
        <el-table-column label="试样名称" prop="sampleName" show-overflow-tooltip></el-table-column>
        <el-table-column label="委托编号" prop="entrustCode" show-overflow-tooltip></el-table-column>
        <el-table-column label="委托编号" prop="entrustCode" show-overflow-tooltip>
          <template slot-scope="scope">{{ scope.row.entrustCode || '待生成' }}</template>
        </el-table-column>
        <el-table-column label="关联状态" min-width="90">
          <template slot-scope="scope">{{ scope.row.bindingStatus === 1 ? '已绑定' : '未绑定' }}</template>
        </el-table-column>
        <el-table-column label="下单状态" min-width="90">
          <template slot-scope="scope">{{ orderStateText(scope.row.orderState) }}</template>
        </el-table-column>
        <el-table-column label="检验进度" prop="insProgress" min-width="90">
          <template slot-scope="scope">{{ scope.row.insProgress || '--' }}</template>
        </el-table-column>
        <el-table-column label="检验结果" min-width="90">
          <template slot-scope="scope">{{ insResultText(scope.row.insResult) }}</template>
        </el-table-column>
        <el-table-column label="报告状态" min-width="90">
          <template slot-scope="scope">{{ reportStatusText(scope.row.reportStatus) }}</template>
        </el-table-column>
        <el-table-column label="委托时间" prop="commissionDate" show-overflow-tooltip></el-table-column>
        <el-table-column label="型号" prop="modelNo" show-overflow-tooltip></el-table-column>
        <el-table-column label="委托单位" prop="commissionUnit" show-overflow-tooltip></el-table-column>
@@ -52,12 +74,13 @@
            <span v-if="scope.row.processing === 0">委托单位取回</span>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" width="240">
        <el-table-column align="center" label="操作" width="320">
          <template slot-scope="scope">
            <el-button size="mini" type="text" @click="goUpdate(scope.row)">编辑</el-button>
            <el-button size="mini" type="text" @click="handleLook(scope.row)">查看</el-button>
            <el-button size="mini" style="color:#F56C6C" type="text" @click="deleteOrder(scope.row)">删除</el-button>
            <el-button size="mini" type="text" @click="openDownloadDia(scope.row)">下载</el-button>
            <el-button :disabled="!scope.row.fileUrl" size="mini" type="text" @click="openDownloadDia(scope.row)">下载</el-button>
            <el-button v-if="canChangeBinding(scope.row)" size="mini" type="text" @click="openChangeBinding(scope.row)">变更关联</el-button>
            <el-upload ref='upload' :action="action" :data="{ inspectionOrderId: scope.row.inspectionOrderId }"
              :headers="uploadHeader" :on-error="onError" :on-success="handleSuccessUp" :show-file-list="false"
              accept='image/jpg,image/jpeg,image/png,application/pdf,.doc,.docx,.xlsx' name="file"
@@ -72,32 +95,6 @@
        @current-change="handleCurrentChange1">
      </el-pagination>
    </div>
    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="orderRowsVisible"
      title="新增检验任务单" width="1000px">
      <div style="display: flex; align-items: center;margin-bottom: 10px">
        <span style="width: 80px">委托编号:</span>
        <el-input v-model="entity.entrustCode" clearable size="small"
          style="width: 300px;margin-right: 10px"></el-input>
        <el-button size="small" type="primary" @click="searchTableData">查询</el-button>
        <el-button size="small" @click="refreshTableData">重 置</el-button>
      </div>
      <el-table v-loading="tableLoading" :data="tableData"
                :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
                height="550" style="width: 100%">
        <el-table-column align="center" label="序号" type="index" width="60"></el-table-column>
        <el-table-column label="委托编号" prop="entrustCode"></el-table-column>
        <el-table-column label="样品名称" prop="sample"></el-table-column>
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button align="center" size="mini" type="text" @click="goAddOrder(scope.row)">新增委托单</el-button>
          </template>
        </el-table-column>
      </el-table>
      <el-pagination :current-page="1" :page-size="tableSearch.size" :page-sizes="[10, 20, 30, 50, 100]" :total="total"
        layout="->,total, sizes, prev, pager, next" style="margin-top: 10px" background @size-change="handleSizeChange"
        @current-change="handleCurrentChange">
      </el-pagination>
    </el-dialog>
    <el-dialog :class="{ downPdf: title == '下载' }" :close-on-click-modal="false" :close-on-press-escape="false"
      :modal="title != '下载'" :title="title" :visible.sync="detailDialogVisible" top="20px" width="1200px">
      <div style="max-height: 75vh;overflow-y: auto;">
@@ -119,19 +116,19 @@
                <p>记录编号: ZTT/QR-16-04-a</p>
              </td>
              <td>
                <p>归档部门:综合室</p>
                <p>归档部门:质量部</p>
              </td>
            </tr>
          </table>
          <h4 style="display: flex;align-items: center;flex-direction: column;justify-content: center;">
            <span style="font-size: 28px;">检 验 委 托 单</span>
          </h4>
          <p v-if="operationType !== 'view'" style="margin-left: 560px;display: flex;align-items: center">
            <span style="width: 100px">委托编号:</span>
            <el-input v-model="currentInfo.entrustCode" clearable size="small"></el-input>
          <p style="margin-left: 560px;display: flex;align-items: center">
            <span style="width: 100px">委托单号:</span>
            <el-input v-model="currentInfo.inspectionOrderCode" disabled placeholder="保存后系统生成" size="small"></el-input>
          </p>
          <p v-if="operationType === 'view'" style="margin-top: 16px;margin-left: 600px;">委托编号:{{
            currentInfo.entrustCode }}
          <p style="margin-top: 16px;margin-left: 600px;">委托编号:{{
            currentInfo.entrustCode || '待生成' }}
          </p>
          <table border="1" cellpadding="10" class="tables" style="width: 100%">
            <tr>
@@ -162,8 +159,10 @@
              <td>
                <p>委托单位</p>
              </td>
              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUnit" clearable
                  size="small"></el-input></td>
              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUnit" disabled
                  placeholder="请选择委托单位" size="small">
                  <template slot="append"><el-button icon="el-icon-search" @click="openCommissionUnitDialog"></el-button></template>
                </el-input></td>
              <td v-if="operationType === 'view'">{{ currentInfo.commissionUnit }}</td>
            </tr>
            <tr>
@@ -176,8 +175,10 @@
              <td>
                <p>委托人</p>
              </td>
              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUser" clearable
                  size="small"></el-input></td>
              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUser" disabled
                  placeholder="请选择委托人" size="small">
                  <template slot="append"><el-button icon="el-icon-search" @click="openCommissionUserDialog"></el-button></template>
                </el-input></td>
              <td v-if="operationType === 'view'">{{ currentInfo.commissionUser }}</td>
            </tr>
            <tr>
@@ -325,8 +326,8 @@
              <td colspan="2">
                <p>委托人联系电话</p>
              </td>
              <td v-if="operationType !== 'view'" colspan="3"><el-input v-model="currentInfo.commissionPhone" clearable
                  size="small"></el-input></td>
              <td v-if="operationType !== 'view'" colspan="3"><el-input v-model="currentInfo.commissionPhone" disabled
                  placeholder="选择委托人后自动带出" size="small"></el-input></td>
              <td v-if="operationType === 'view'" colspan="3">{{ currentInfo.commissionPhone }}</td>
            </tr>
            <tr>
@@ -350,8 +351,8 @@
              <td colspan="2">
                <p>领样员签名</p>
              </td>
              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.sampleTakerUser" clearable
                  size="small"></el-input></td>
              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.sampleTakerUser" disabled
                  placeholder="下单关联后自动记录当前登录人" size="small"></el-input></td>
              <td v-if="operationType === 'view'">{{ currentInfo.sampleTakerUser }}</td>
              <td>
                <p>领样日期</p>
@@ -368,17 +369,17 @@
                <p>检测机构信息</p>
              </td>
              <td colspan="3">
                <p>江苏中天科技股份有限公司检测中心</p>
                <p>江苏中天科技股份有限公司(软电缆检测室)</p>
              </td>
            </tr>
            <tr>
              <td colspan="3">
                <p>地址:江苏省南通市经济技术开发区新开南路 19 号</p>
                <p>地址:江苏省南通市如东县河口镇中天村五组168号</p>
              </td>
            </tr>
            <tr>
              <td colspan="3">
                <p>电话:0513-89059043</p>
                <p>电话:0513-84882686</p>
              </td>
            </tr>
          </table>
@@ -402,18 +403,53 @@
        <el-button @click="downloadDialog = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="changeBindingVisible" title="变更关联委托单" width="500px" append-to-body>
      <el-form ref="bindingForm" :model="bindingForm" :rules="bindingRules" label-width="100px">
        <el-form-item label="新的委托单" prop="inspectionOrderId">
          <el-select v-model="bindingForm.inspectionOrderId" filterable remote reserve-keyword
            :remote-method="searchUnboundInspectionOrders" :loading="bindingLoading" placeholder="请选择未绑定委托单"
            style="width: 100%" @focus="loadUnboundInspectionOrders">
            <el-option v-for="item in unboundInspectionOrders" :key="item.inspectionOrderId"
              :label="`${item.inspectionOrderCode} / ${item.sampleName || ''}`" :value="item.inspectionOrderId" />
          </el-select>
        </el-form-item>
        <el-form-item label="变更原因" prop="reason">
          <el-input v-model="bindingForm.reason" type="textarea" :rows="3" maxlength="200" show-word-limit />
        </el-form-item>
      </el-form>
      <span slot="footer">
        <el-button @click="changeBindingVisible = false">取 消</el-button>
        <el-button type="primary" :loading="bindingSubmitting" @click="submitChangeBinding">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="commissionUnitDialogVisible" title="选择委托单位" width="70%" append-to-body>
      <lims-table :tableData="commissionUnitList" :column="commissionUnitColumns" :isSelection="true"
        :handleSelectionChange="selectCommissionUnit" @pagination="changeCommissionUnitPage" :height="400"
        :page="commissionUnitPage" :tableLoading="commissionUnitLoading" />
      <span slot="footer"><el-button @click="commissionUnitDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmCommissionUnit">确 定</el-button></span>
    </el-dialog>
    <el-dialog :visible.sync="commissionUserDialogVisible" title="选择委托人" width="70%" append-to-body>
      <lims-table :tableData="commissionUserList" :column="commissionUserColumns" :isSelection="true"
        :handleSelectionChange="selectCommissionUser" :height="400" :page="{ total: commissionUserList.length, size: 100, current: 1 }" />
      <span slot="footer"><el-button @click="commissionUserDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmCommissionUser">确 定</el-button></span>
    </el-dialog>
  </div>
</template>
<script>
import {
  addInspectionOrder, delInspectionOrder, exportInspectionOrder,
  getInsOrderOnInspection, getInspectionOrderByInsOderId, getInspectionOrderOne,
  changeInspectionOrderBinding,
  getInspectionOrderOne,
  pageUnboundInspectionOrder,
  pageInspectionOrder,
  updateInspectionOrder
} from "@/api/cnas/process/demand/demand";
import limsTable from "@/components/Table/lims-table.vue";
import { selectUserCondition } from "@/api/business/inspectionTask";
import { selectCustomPageList } from "@/api/system/customer";
export default {
  name: "Demand",
@@ -450,25 +486,15 @@
        },
      ],
      operationType: '',
      orderRowsVisible: false,
      tableList: [],
      tableListLoading: false,
      pages: {
        current: 1,
        size: 20,
      },
      tableData: [],
      tableLoading: false,
      tableSearch: {
        current: 1,
        size: 20,
      },
      total: 0,
      total1: 0,
      entity: {
        entrustCode: ''
      },
      entitySearch: {
        inspectionOrderCode: '',
        sampleName: '',
        commissionUnit: '',
        production: '',
@@ -477,6 +503,38 @@
      buttonLoading: false,
      downloadDialog: false,
      download: {},
      changeBindingVisible: false,
      bindingLoading: false,
      bindingSubmitting: false,
      unboundInspectionOrders: [],
      bindingForm: {
        insOrderId: null,
        inspectionOrderId: null,
        reason: ''
      },
      bindingRules: {
        inspectionOrderId: [{ required: true, message: '请选择新的委托单', trigger: 'change' }],
        reason: [{ required: true, message: '请输入变更原因', trigger: 'blur' }]
      },
      commissionUnitDialogVisible: false,
      commissionUnitLoading: false,
      commissionUnitList: [],
      commissionUnitSelection: [],
      commissionUnitPage: { total: 0, size: 10, current: 1 },
      commissionUnitColumns: [
        { label: '客户名称', prop: 'company' },
        { label: '客户单位EN', prop: 'companyEn' },
        { label: '单位地址', prop: 'address' },
        { label: '单位电话', prop: 'phone' }
      ],
      commissionUserDialogVisible: false,
      commissionUserList: [],
      commissionUserSelection: [],
      commissionUserColumns: [
        { label: '姓名', prop: 'name' },
        { label: '账号', prop: 'account' },
        { label: '联系电话', prop: 'phone' }
      ],
    };
  },
  mounted() {
@@ -489,6 +547,122 @@
    }
  },
  methods: {
    openCommissionUnitDialog() {
      this.commissionUnitSelection = []
      this.commissionUnitDialogVisible = true
      this.loadCommissionUnitList()
    },
    loadCommissionUnitList() {
      this.commissionUnitLoading = true
      selectCustomPageList({ ...this.commissionUnitPage }).then(res => {
        this.commissionUnitList = res.data.records || []
        this.commissionUnitPage.total = res.data.total || 0
      }).finally(() => { this.commissionUnitLoading = false })
    },
    changeCommissionUnitPage({ page, limit }) {
      this.commissionUnitPage.current = page
      this.commissionUnitPage.size = limit
      this.loadCommissionUnitList()
    },
    selectCommissionUnit(rows) { this.commissionUnitSelection = rows },
    confirmCommissionUnit() {
      if (this.commissionUnitSelection.length !== 1) {
        this.$message.error('请选择一条委托单位')
        return
      }
      const custom = this.commissionUnitSelection[0]
      this.currentInfo.commissionUnitId = custom.id
      this.currentInfo.commissionUnit = custom.company
      this.commissionUnitDialogVisible = false
    },
    openCommissionUserDialog() {
      this.commissionUserSelection = []
      this.commissionUserDialogVisible = true
      selectUserCondition().then(res => { this.commissionUserList = res.data || [] })
    },
    selectCommissionUser(rows) { this.commissionUserSelection = rows },
    confirmCommissionUser() {
      if (this.commissionUserSelection.length !== 1) {
        this.$message.error('请选择一位委托人')
        return
      }
      const user = this.commissionUserSelection[0]
      this.currentInfo.commissionUserId = user.id
      this.currentInfo.commissionUser = user.name
      this.currentInfo.commissionPhone = user.phone || ''
      this.commissionUserDialogVisible = false
    },
    loadDefaultCommissionUnit() {
      selectCustomPageList({ current: 1, size: 10, company: '中天科技装备电缆有限公司' }).then(res => {
        const custom = (res.data.records || []).find(item => item.company === '中天科技装备电缆有限公司')
        if (custom) {
          this.currentInfo.commissionUnitId = custom.id
          this.currentInfo.commissionUnit = custom.company
        } else {
          this.$message.warning('未找到默认委托单位,请手动选择')
        }
      })
    },
    orderStateText(state) {
      const states = {
        0: '待审核',
        1: '检验中',
        2: '退回',
        3: '撤销',
        4: '已检验'
      }
      return state === null || state === undefined ? '未下单' : (states[state] || '--')
    },
    insResultText(result) {
      const results = {
        0: '不合格',
        1: '合格',
        3: '不判定'
      }
      return result === null || result === undefined ? '待检验' : (results[result] || '--')
    },
    reportStatusText(status) {
      const statuses = {
        0: '未生成',
        1: '待同步',
        2: '可下载'
      }
      return statuses[status] || '未生成'
    },
    canChangeBinding(row) {
      return row.insOrderId && (row.orderState === 0 || row.orderState === 2) && !row.entrustCode
    },
    openChangeBinding(row) {
      this.bindingForm = { insOrderId: row.insOrderId, inspectionOrderId: null, reason: '' }
      this.unboundInspectionOrders = []
      this.changeBindingVisible = true
      this.loadUnboundInspectionOrders()
      this.$nextTick(() => this.$refs.bindingForm && this.$refs.bindingForm.clearValidate())
    },
    loadUnboundInspectionOrders() {
      this.searchUnboundInspectionOrders('')
    },
    searchUnboundInspectionOrders(keyword) {
      this.bindingLoading = true
      pageUnboundInspectionOrder({ current: 1, size: 20, inspectionOrderCode: keyword }).then(res => {
        this.unboundInspectionOrders = res.data.records || []
      }).finally(() => {
        this.bindingLoading = false
      })
    },
    submitChangeBinding() {
      this.$refs.bindingForm.validate(valid => {
        if (!valid) return
        this.bindingSubmitting = true
        changeInspectionOrderBinding(this.bindingForm).then(() => {
          this.$message.success('关联已变更')
          this.changeBindingVisible = false
          this.refreshTable()
        }).finally(() => {
          this.bindingSubmitting = false
        })
      })
    },
    addOrderDetailList() {
      if (this.currentInfo.orderDetailList == null) {
        this.currentInfo.orderDetailList = []
@@ -518,6 +692,7 @@
    // 重置
    refresh() {
      this.entitySearch = {
        inspectionOrderCode: '',
        sampleName: '',
        commissionUnit: '',
        production: '',
@@ -533,42 +708,15 @@
    goAdd() {
      this.operationType = 'add'
      this.title = '新增检验委托单';
      this.orderRowsVisible = true
      this.searchTableData()
    },
    // 查询可新增的检验单
    searchTableData() {
      this.tableLoading = true
      getInsOrderOnInspection({
        ...this.tableSearch,
        ...this.entity
      }).then(res => {
        this.tableLoading = false
        this.tableData = res.data.records
        this.total = res.data.total
      }).catch(err => {
        this.tableLoading = false
      })
    },
    // 重置检验单列表
    refreshTableData() {
      this.entity = {
        entrustCode: ''
      this.currentInfo = {
        isLeave: 1,
        processing: 0,
        send: 1,
        criterionRule: 0,
        orderDetailList: []
      }
      this.tableSearch = {
        current: 1,
        size: 20,
      }
      this.searchTableData()
    },
    // 检验单列表分页
    handleSizeChange(val) {
      this.tableSearch.size = val
      this.searchTableData();
    },
    handleCurrentChange(val) {
      this.tableSearch.current = val
      this.searchTableData();
      this.detailDialogVisible = true
      this.loadDefaultCommissionUnit()
    },
    // 列表分页
    handleSizeChange1(val) {
@@ -584,9 +732,8 @@
      this.buttonLoading = true
      addInspectionOrder(this.currentInfo).then(res => {
        this.buttonLoading = false
        this.$message.success('新增成功')
        this.$message.success(`新增成功,委托单号:${res.data.inspectionOrderCode}`)
        this.detailDialogVisible = false
        this.orderRowsVisible = false
        this.refreshTable()
      }).catch(err => {
        this.buttonLoading = false
@@ -597,22 +744,11 @@
      this.buttonLoading = true
      updateInspectionOrder(this.currentInfo).then(res => {
        this.buttonLoading = false
        this.$message.success('新增成功')
        this.$message.success('修改成功')
        this.detailDialogVisible = false
        this.orderRowsVisible = false
        this.refreshTable()
      }).catch(err => {
        this.buttonLoading = false
      })
    },
    // 查询需要新增的委托单详情
    goAddOrder(row) {
      getInspectionOrderByInsOderId({ insOrderId: row.id }).then(res => {
        this.currentInfo = res.data
        this.title = '新增检验委托单';
        this.detailDialogVisible = true
      }).catch(err => {
        console.log('err----', err)
      })
    },
    // 打开编辑弹框
src/views/business/productOrder/components/addOrder.vue
@@ -49,6 +49,15 @@
                <el-input v-model="addObj.entrustCode" clearable disabled placeholder="系统生成" size="small"></el-input>
              </el-form-item>
            </el-col>
            <el-col v-if="active == 1" :span="6">
              <el-form-item label="检验委托单:" prop="inspectionOrderId">
                <el-input v-model="addObj.inspectionOrderCode" disabled placeholder="请选择检验委托单" size="small" style="width: 208px">
                  <template slot="append">
                    <el-button slot="append" icon="el-icon-search" @click="openInspectionOrderList"></el-button>
                  </template>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="6">
              <el-form-item label="检验类别:" prop="orderType">
                <el-select v-model="addObj.orderType" :disabled="active>1&&tabIndex!=4" clearable size="small" style="width: 100%;">
@@ -61,6 +70,8 @@
                <el-input v-model="addObj.custom" disabled size="small" clearable></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="委托单位:" prop="company">
                <el-input v-model="addObj.company" disabled placeholder="选择委托单位" size="small" style="width: 208px">
@@ -71,8 +82,6 @@
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="IFS域:" prop="contract">
                <el-select v-model="addObj.contract" clearable placeholder="请选择" size="small">
@@ -93,14 +102,14 @@
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="零件描述:" prop="partDesc">
                <el-input v-model="addObj.partDesc" clearable placeholder="请输入零件描述" size="small">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="6">
              <el-form-item label="联系方式:" prop="phone">
                <el-input v-model="addObj.phone" :disabled="active>1&&tabIndex!=4" clearable placeholder="选择委托客户" size="small"></el-input>
@@ -431,6 +440,28 @@
        <el-button type="primary" @click="selectUser">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="inspectionOrderDialogVisible" title="选择检验委托单" width="70%">
      <div v-if="inspectionOrderDialogVisible" class="body">
        <el-form :inline="true" :model="inspectionOrderQuery" size="small">
          <el-form-item label="委托单号">
            <el-input v-model="inspectionOrderQuery.inspectionOrderCode" clearable placeholder="请输入委托单号"
              @keyup.enter.native="queryInspectionOrders"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="queryInspectionOrders">查询</el-button>
            <el-button @click="resetInspectionOrderQuery">重置</el-button>
          </el-form-item>
        </el-form>
        <lims-table :tableData="inspectionOrderTableData" :column="inspectionOrderColumns"
                    :isSelection="true" :handleSelectionChange="selectInspectionOrderRows"
                    @pagination="inspectionOrderPagination" :height="450" key="inspectionOrderTableData"
                    :page="inspectionOrderPage" :tableLoading="inspectionOrderLoading"></lims-table>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="inspectionOrderDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="confirmInspectionOrder">确 定</el-button>
      </span>
    </el-dialog>
    <el-dialog :visible.sync="selectStandardTree" title="选择样品" width="500px">
      <div v-if="selectStandardTree" v-loading="selectStandardTreeLoading" class="body"  style="height: 60vh;overflow-y: auto;user-select: none;">
        <el-row>
@@ -633,6 +664,11 @@
import { bigEval } from "@/utils/bigEval";
import {mapGetters} from "vuex";
import {addQuarter, updateQuarterOnOrder} from "@/api/business/finishedProductSampling";
import {
  addInsOrderWithInspectionOrder,
  getInspectionOrderForPlaceOrder,
  pageUnboundInspectionOrder
} from "@/api/cnas/process/demand/demand";
export default {
  name: 'AddOrder',
@@ -663,6 +699,8 @@
      templates: [],
      addObj: {
        entrustCode: null,
        inspectionOrderId: null,
        inspectionOrderCode: null,
        contract:null,
        updateBatchNo: null,
        partDesc: null,
@@ -765,6 +803,26 @@
        unit: null
      },
      type: [],
      inspectionOrderLoading: false,
      inspectionOrderDialogVisible: false,
      inspectionOrderTableData: [],
      inspectionOrderSelection: [],
      inspectionOrderQuery: {
        inspectionOrderCode: ''
      },
      inspectionOrderPage: {
        total: 0,
        size: 10,
        current: 1
      },
      inspectionOrderColumns: [
        {label: '委托单号', prop: 'inspectionOrderCode'},
        {label: '试样名称', prop: 'sampleName'},
        {label: '委托单位', prop: 'commissionUnit'},
        {label: '生产单位', prop: 'production'},
        {label: '委托人', prop: 'commissionUser'},
        {label: '委托时间', prop: 'commissionDate'}
      ],
      selectUserDia: false,
      tableData1: [],
      tableLoading1: false,
@@ -917,6 +975,85 @@
    this.getInfo();
  },
  methods: {
    openInspectionOrderList() {
      this.inspectionOrderSelection = []
      this.inspectionOrderQuery.inspectionOrderCode = ''
      this.inspectionOrderPage.current = 1
      this.inspectionOrderDialogVisible = true
      this.getInspectionOrderList()
    },
    getInspectionOrderList() {
      this.inspectionOrderLoading = true
      pageUnboundInspectionOrder({
        ...this.inspectionOrderPage,
        ...this.inspectionOrderQuery
      }).then(res => {
        this.inspectionOrderTableData = res.data.records || []
        this.inspectionOrderPage.total = res.data.total || 0
      }).finally(() => {
        this.inspectionOrderLoading = false
      })
    },
    queryInspectionOrders() {
      this.inspectionOrderPage.current = 1
      this.getInspectionOrderList()
    },
    resetInspectionOrderQuery() {
      this.inspectionOrderQuery.inspectionOrderCode = ''
      this.queryInspectionOrders()
    },
    inspectionOrderPagination({ page, limit }) {
      this.inspectionOrderPage.current = page
      this.inspectionOrderPage.size = limit
      this.getInspectionOrderList()
    },
    selectInspectionOrderRows(rows) {
      this.inspectionOrderSelection = rows
    },
    confirmInspectionOrder() {
      if (this.inspectionOrderSelection.length !== 1) {
        this.$message.error(this.inspectionOrderSelection.length === 0 ? '请选择一条检验委托单' : '只能选择一条检验委托单')
        return
      }
      const inspectionOrder = this.inspectionOrderSelection[0]
      this.addObj.inspectionOrderId = inspectionOrder.inspectionOrderId
      this.addObj.inspectionOrderCode = inspectionOrder.inspectionOrderCode
      this.inspectionOrderDialogVisible = false
      this.handleInspectionOrderChange(inspectionOrder.inspectionOrderId)
    },
    handleInspectionOrderChange(inspectionOrderId) {
      if (!inspectionOrderId) {
        this.addObj.inspectionOrderCode = null
        return
      }
      getInspectionOrderForPlaceOrder({ inspectionOrderId }).then(res => {
        const inspectionOrder = res.data
        this.addObj.inspectionOrderCode = inspectionOrder.inspectionOrderCode
        this.addObj.sample = inspectionOrder.sampleName || this.addObj.sample
        this.addObj.company = inspectionOrder.commissionUnit || this.addObj.company
        this.addObj.companyId = inspectionOrder.commissionUnitId || this.addObj.companyId
        this.addObj.production = inspectionOrder.production || this.addObj.production
        this.addObj.prepareUser = inspectionOrder.commissionUser || this.addObj.prepareUser
        this.addObj.phone = inspectionOrder.commissionPhone || this.addObj.phone
        this.addObj.sampleStatus = inspectionOrder.sampleStatus || this.addObj.sampleStatus
        this.addObj.isLeave = inspectionOrder.isLeave === null || inspectionOrder.isLeave === undefined
          ? this.addObj.isLeave : inspectionOrder.isLeave
        this.addObj.processing = inspectionOrder.processing === null || inspectionOrder.processing === undefined
          ? this.addObj.processing : inspectionOrder.processing
        this.addObj.appointed = inspectionOrder.appointed || this.addObj.appointed
        this.addObj.send = inspectionOrder.send === null || inspectionOrder.send === undefined
          ? this.addObj.send : inspectionOrder.send
        if (/^\d+$/.test(inspectionOrder.quantity || '')) {
          this.addObj.sampleNum = Number(inspectionOrder.quantity)
        }
        this.sample.sample = inspectionOrder.sampleName || this.sample.sample
        this.sample.model = inspectionOrder.modelNo || this.sample.model
        this.$message.success('已带入检验委托单信息')
      }).catch(() => {
        this.addObj.inspectionOrderId = null
        this.addObj.inspectionOrderCode = null
      })
    },
    getInfo() {
      this.selectStandardTreeList()
      this.getAuthorizedPerson();
@@ -1413,7 +1550,18 @@
        })
      }else{
        // 常规提交
        addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
        const { inspectionOrderId, inspectionOrderCode, ...insOrder } = this.addObj
        const submitRequest = inspectionOrderId
          ? addInsOrderWithInspectionOrder({
            inspectionOrderId,
            insOrder: {...insOrder, typeSource: -1},
            sampleList: sampleList
          })
          : addInsOrder({
            insOrder: {...insOrder, typeSource: -1},
            sampleList: sampleList
          })
        submitRequest.then(res => {
          this.saveLoad = false
          this.$message.success('已提交')
          this.bsm3Dia = false;
@@ -1494,7 +1642,7 @@
          this.addObj.phone = selects.phone
          this.addObj.companyId = selects.departId
          this.addObj.production = '中天耐丝有限公司'
          this.addObj.productionEn = 'Zhongtian Naisi Co., Ltd.'
          this.addObj.productionEn = 'Zhongtian intelligent cable Co.,Ltd.'
          if(this.active==1){
            this.selectInsOrderTemplate()
          }