| | |
| | | </div> |
| | | <div v-show="!cableConfigShow&&!auxiliaryShow" class="order-body"> |
| | | <el-card shadow="never" class="order-card"> |
| | | <el-form ref="newJuOrder" class="newju-order-form" :model="addObj" size="small" label-width="108px" |
| | | <el-form ref="newJuOrder" class="newju-order-form" :model="addObj" :rules="newJuOrderRules" size="small" label-width="108px" |
| | | label-position="right"> |
| | | <el-row :gutter="16"> |
| | | <el-col :span="6"> |
| | |
| | | </el-form-item> |
| | | </el-col> |
| | | <el-col :span="6"> |
| | | <el-form-item label="送样日期"> |
| | | <el-form-item label="送样日期" prop="sampleDate"> |
| | | <el-date-picker v-model="addObj.sampleDate" type="date" value-format="yyyy-MM-dd" :disabled="active>1" |
| | | size="small"/> |
| | | </el-form-item> |
| | |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="addObj.remark" :disabled="active>1" size="small" |
| | | placeholder="可选,补充说明委托事项"/> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | | <el-row :gutter="16"> |
| | | <el-col :span="24"> |
| | | <el-form-item label="附件"> |
| | | <el-upload ref="orderFileUpload" action="#" :auto-upload="false" multiple :file-list="fileList" |
| | | :disabled="active>1" :on-change="handleFileChange" :on-remove="handleFileRemove"> |
| | | <el-button :disabled="active>1" size="small" type="primary">选择附件</el-button> |
| | | <div slot="tip" class="el-upload__tip">支持多文件上传,单个文件不超过200MB</div> |
| | | </el-upload> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | getInsOrder, |
| | | getUserNow, selectInsOrderTemplate, |
| | | selectStandardMethodEnum, selectStandardProductList, |
| | | selectStandardTreeList2 |
| | | selectStandardTreeList2, getFileList, delFile |
| | | } from "@/api/business/rawMaterialOrder"; |
| | | import { |
| | | addInsOrder, addInsOrderTemplate, delInsOrderTemplate, |
| | | getQuarterOnOrder, judgeNotSpotCheckOrder, selectInsOrderTemplateById, |
| | | updateInsOrder, |
| | | updateNewJuInsOrder, |
| | | upInsOrder, |
| | | upInsOrderOfState |
| | | } from "@/api/business/add"; |
| | | import {selectUserCondition} from "@/api/performance/class"; |
| | | import {uploadFile} from "@/api/business/inspectionTask"; |
| | | import {selectTemplateBindings, selectsStandardMethodByFLSSM} from "@/api/standard/standardLibrary"; |
| | | import limsTable from "@/components/Table/lims-table.vue"; |
| | | import {selectCustomPageList} from "@/api/system/customer"; |
| | |
| | | active: '', |
| | | tabIndex: '', |
| | | currentId: '', |
| | | isEdit: false, |
| | | hasActivated: false, |
| | | orderLoadVersion: 0, |
| | | sampleCode: '', |
| | | fileList: [], |
| | | deleteFileIds: [], |
| | | boundTemplateList: [], |
| | | templateBindingLoading: false, |
| | | sampleSelectionList: [],//样品表格选中数据 |
| | |
| | | reportDelivery: 1, |
| | | reportAddress: '', |
| | | reportReceiver: '', |
| | | }, |
| | | newJuOrderRules: { |
| | | sampleDate: [{required: true, message: '请选择送样日期', trigger: 'change'}], |
| | | }, |
| | | addObjRules: { // 表单校验规则 |
| | | orderType: [ |
| | |
| | | } |
| | | }, |
| | | watch: { |
| | | '$route'(to, from) { |
| | | if (to.path === from.path && to.fullPath !== from.fullPath && to.name === 'AddOrder') { |
| | | this.loadRouteOrder(true) |
| | | } |
| | | }, |
| | | // sampleList() { |
| | | // this.addObj.method = null |
| | | // this.productList = [] |
| | |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.active = this.$route.query.active |
| | | this.tabIndex = this.$route.query.tabIndex |
| | | this.currentId = this.$route.query.currentId |
| | | this.getUserNowData() |
| | | this.getInfo() |
| | | if (this.tabIndex == 4 && this.active == 2) { |
| | | this.isSpecial = true |
| | | } else { |
| | | this.isSpecial = false |
| | | } |
| | | this.loadRouteOrder(false) |
| | | }, |
| | | activated() { |
| | | if (!this.hasActivated) { |
| | | this.hasActivated = true |
| | | return |
| | | } |
| | | this.loadRouteOrder(true) |
| | | }, |
| | | methods: { |
| | | loadRouteOrder(reset) { |
| | | if (reset) this.resetOrderPage() |
| | | this.active = this.$route.query.active |
| | | this.tabIndex = this.$route.query.tabIndex |
| | | this.currentId = this.$route.query.currentId |
| | | this.getInfo(); |
| | | this.isEdit = this.$route.query.edit == 1 |
| | | if (this.active == 1 && !this.isEdit) this.getUserNowData() |
| | | this.getInfo() |
| | | this.isSpecial = this.tabIndex == 4 && this.active == 2 |
| | | }, |
| | | methods: { |
| | | resetOrderPage() { |
| | | this.orderLoadVersion++ |
| | | const defaults = this.$options.data.call(this) |
| | | const fields = ['addObj', 'sample', 'sampleCode', 'fileList', 'deleteFileIds', |
| | | 'boundTemplateList', 'sampleSelectionList', 'editTable', 'sampleList', |
| | | 'productList', 'productList0', 'productIds', 'sampleIds', 'selectTree', |
| | | 'selectTreeNode', 'selectiveEcho', 'specialStandardMethod', 'model', |
| | | 'standardMethodListId', 'template', 'templates', 'addObj1', 'totalArr', |
| | | 'methodS', 'inspectionItem', 'inspectionItemSubclass', 'currentMethod', |
| | | 'filters', 'selectStandardTree', 'search', 'expandedKeys', 'sampleViewEn' |
| | | ] |
| | | fields.forEach(key => { this[key] = defaults[key] }) |
| | | if (this.$refs.orderFileUpload) this.$refs.orderFileUpload.clearFiles() |
| | | if (this.$refs.newJuOrder) this.$refs.newJuOrder.clearValidate() |
| | | }, |
| | | /** |
| | | * 获取小数的最大位数 |
| | | * @param number 型号参数 |
| | |
| | | this.selectStandardTreeList() |
| | | this.getAuthorizedPerson(); |
| | | this.selectStandardMethods() |
| | | if (this.active != 1) { |
| | | if (this.active != 1 || this.isEdit) { |
| | | const orderId = this.currentId |
| | | const loadVersion = this.orderLoadVersion |
| | | // 查看/审核流程 |
| | | // 请求接口,回显数据 |
| | | getInsOrder({ |
| | | orderId: this.currentId |
| | | orderId |
| | | }).then(res => { |
| | | if (loadVersion !== this.orderLoadVersion || orderId !== this.currentId) return |
| | | this.addObj = { |
| | | ...res.data.insOrder |
| | | }; |
| | | if (res.data.standardTreeId) { |
| | | this.$set(this.addObj, 'standardTreeId', res.data.standardTreeId) |
| | | } else if (this.isEdit) { |
| | | this.$message.warning('原标准与订单模板无法唯一匹配,请重新选择检测依据') |
| | | } |
| | | this.addObj.type = String(this.addObj.type) |
| | | const samples = this.HaveJson(res.data.sampleProduct) |
| | | this.sampleCode = res.data.sampleCode || (samples.length ? samples[0].sampleCode || '' : '') |
| | | this.boundTemplateList = this.sortTemplateList(res.data.templateList) |
| | | this.loadOrderFiles() |
| | | const loadSamples = this.canSelectProduct |
| | | ? Promise.all(samples.map(sample => this.loadSelectableProducts(sample))) |
| | | : Promise.resolve(samples) |
| | | loadSamples.then(sampleList => { |
| | | if (loadVersion !== this.orderLoadVersion || orderId !== this.currentId) return |
| | | this.sampleList = sampleList |
| | | this.specialStandardMethod = this.sampleList[0].specialStandardMethod |
| | | this.getProNum() |
| | |
| | | this.addObj.code = this.multipleSelection[0].code |
| | | this.addObj.companyId = this.multipleSelection[0].id |
| | | this.selectUserDia = false |
| | | if (this.active == 1) { |
| | | if (this.active === 1) { |
| | | // TODO |
| | | this.selectInsOrderTemplate() |
| | | } |
| | |
| | | return str.replaceAll(find, value); |
| | | }, |
| | | save() { |
| | | if (this.isEdit && !this.addObj.standardTreeId) { |
| | | this.$message.error('请重新选择检测依据及原始记录模板') |
| | | return; |
| | | } |
| | | if (!this.addObj.sampleDate) { |
| | | this.$refs.newJuOrder.validateField('sampleDate'); |
| | | return; |
| | | } |
| | | if (this.addObj.standardTreeId) { |
| | | if (!this.addObj.sample || !this.addObj.company || !this.addObj.orderType || !this.addObj.testQuantity) { |
| | | this.$message.error('请填写检测依据、委托单位、检验类别和样品数量'); |
| | |
| | | } |
| | | if (this.addObj.subcontractType == null || this.addObj.sampleDisposal == null |
| | | || this.addObj.resultEvaluation == null || this.addObj.reportDelivery == null) { |
| | | this.$message.error('请选择分包内容、样品处置、对结果评价和报告交付方式'); |
| | | this.$message.error('请选择委托单位'); |
| | | return; |
| | | } |
| | | if (this.addObj.subcontractType === 1 && !this.addObj.subcontractCompany) { |
| | |
| | | if (this.addObj.quarterItemId) { |
| | | this.addObj.quarterItemId = this.addObj.quarterItemId[1] |
| | | } |
| | | if (this.addObj.createTime) { |
| | | delete this.addObj.createTime |
| | | } |
| | | if (this.addObj.orderType === '抽检') { |
| | | judgeNotSpotCheckOrder({insOrder: this.addObj, sampleList: sampleList}).then(res => { |
| | | if (res.data === true) { |
| | |
| | | ? null : this.addObj.productionDate, |
| | | typeSource: -1, |
| | | } |
| | | delete insOrder.createTime |
| | | if (this.tabIndex == 4 && this.active == 2) { |
| | | // 退回后提交 |
| | | updateInsOrder({insOrder, sampleProduct: sampleList}).then(res => { |
| | |
| | | templateList: this.boundTemplateList.map((item, index) => ({templateId: item.templateId, sort: index})) |
| | | } |
| | | : {insOrder, sampleList: sampleList} |
| | | addInsOrder(payload).then(res => { |
| | | const request = this.isEdit |
| | | ? updateNewJuInsOrder({...payload, orderId: this.currentId}) |
| | | : addInsOrder(payload) |
| | | request.then(async res => { |
| | | const orderId = this.isEdit ? this.currentId : res.data |
| | | const fileSuccess = await this.saveOrderFiles(orderId) |
| | | this.saveLoad = false |
| | | this.$message.success('已提交') |
| | | if (!fileSuccess) { |
| | | this.$message.warning('订单已保存,部分附件处理失败,请重试') |
| | | this.currentId = orderId |
| | | this.isEdit = true |
| | | this.loadOrderFiles() |
| | | return |
| | | } |
| | | this.$message.success(this.isEdit ? '修改成功' : '已提交') |
| | | this.bsm3Dia = false; |
| | | this.closeOpenPage() |
| | | }).catch(e => { |
| | | this.saveLoad = false |
| | | }) |
| | | } |
| | | }, |
| | | handleFileChange(file, fileList) { |
| | | if (file.size > 200 * 1024 * 1024) { |
| | | this.$message.error('单个附件不能超过200MB') |
| | | this.fileList = fileList.filter(item => item.uid !== file.uid) |
| | | return |
| | | } |
| | | this.fileList = fileList |
| | | }, |
| | | handleFileRemove(file, fileList) { |
| | | if (file.id) { |
| | | this.deleteFileIds.push(file.id) |
| | | } |
| | | this.fileList = fileList |
| | | }, |
| | | loadOrderFiles() { |
| | | if (!this.currentId) return |
| | | const orderId = this.currentId |
| | | const loadVersion = this.orderLoadVersion |
| | | getFileList({insOrderId: orderId, current: -1, size: -1}).then(res => { |
| | | if (loadVersion !== this.orderLoadVersion || orderId !== this.currentId) return |
| | | this.fileList = (res.data.records || []).map(item => ({ |
| | | name: item.fileName, |
| | | id: item.id, |
| | | status: 'success' |
| | | })) |
| | | }) |
| | | }, |
| | | async saveOrderFiles(orderId) { |
| | | try { |
| | | for (const id of this.deleteFileIds) { |
| | | await delFile({id}) |
| | | } |
| | | this.deleteFileIds = [] |
| | | for (const file of this.fileList) { |
| | | if (file.id || !file.raw) continue |
| | | const formData = new FormData() |
| | | formData.append('orderId', orderId) |
| | | formData.append('file', file.raw) |
| | | const res = await uploadFile(formData) |
| | | if (res.code !== 200 || !res.data) return false |
| | | file.id = res.data |
| | | } |
| | | return true |
| | | } catch (e) { |
| | | return false |
| | | } |
| | | }, |
| | | upInsOrderOfState(state) { |
| | |
| | | }) |
| | | }, |
| | | getUserNowData() { |
| | | const loadVersion = this.orderLoadVersion |
| | | this.addObj.prepareUserEn = this.nameEn |
| | | this.addObj.prepareCode = this.userName |
| | | getUserNow().then(res => { |
| | | if (loadVersion !== this.orderLoadVersion || this.active != 1 || this.isEdit) return |
| | | let selects = res.data |
| | | if (selects == null) return |
| | | this.addObj.userId = selects.id |