<template>
|
<div>
|
<j-modal
|
:title='title'
|
:width='width'
|
:visible='visible'
|
switchFullscreen
|
@ok='handleOk'
|
:okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
|
@cancel='handleCancel'
|
cancelText='关闭'>
|
|
<a-spin :spinning='confirmLoading'>
|
<j-form-container :disabled='disableSubmit'>
|
<a-form-model ref='form' :model='model' :rules='validatorRules' slot='detail'>
|
<a-row>
|
<a-col :span='24'>
|
<a-form-model-item label='选择产品' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='prodId'>
|
<j-search-select-tag @change='proChange($event)' placeholder='请选择产品' v-model='model.prodId'
|
:dictOptions='proOptions' />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='24'>
|
<a-form-model-item label='批次类型' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='batchType'>
|
<j-dict-select-tag @change='batchTypeChange($event)' v-model='model.batchType' title='批次类型'
|
dictCode='testing_batch_type' placeholder='请选择批次类型' />
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='24'>
|
<a-form-model-item label='批次号' :labelCol='labelCol' :wrapperCol='wrapperCol' prop='batchCode'>
|
<a-input v-model='model.batchCode' placeholder='请输入批次号'></a-input>
|
</a-form-model-item>
|
</a-col>
|
<a-col :span='24'>
|
<a-form-model-item label='型号通道' :labelCol='labelCol' :wrapperCol='wrapperCol'>
|
<div style='width: 100%;background-color: white;border: 1px dashed lightgray;padding: 0 10px'>
|
<a-list item-layout='horizontal' :data-source='channelInfoList'>
|
<a-list-item slot='renderItem' slot-scope='item, index'>
|
<div style='display: flex;align-items: center;'>
|
<span>{{ item.modelName }}</span>
|
<span><a-input-number :min='1' style='width: 60px;margin: 0 10px' v-model='item.sampleNum'></a-input-number></span>
|
<span>个</span>
|
<span style='margin-left: 20px'>通道:</span>
|
<!-- <a-radio-group v-model='item.channelNum'>
|
<a-radio v-for='i in item.num' :value='i' :key='i'>
|
{{ i }}
|
</a-radio>
|
</a-radio-group>-->
|
|
<a-checkbox-group
|
v-model="item.channelNum"
|
:options="createOptions(item.num)"
|
@change="onCbChange(item,$event)"
|
/>
|
</div>
|
</a-list-item>
|
</a-list>
|
</div>
|
</a-form-model-item>
|
</a-col>
|
|
</a-row>
|
</a-form-model>
|
</j-form-container>
|
</a-spin>
|
|
|
</j-modal>
|
</div>
|
</template>
|
|
<script>
|
import { queryProductList, queryProModelList } from '@api/lims'
|
import { postAction } from '@api/manage'
|
|
export default {
|
name: 'LimsTestingBatchModal2',
|
data() {
|
return {
|
title: '',
|
width: 800,
|
visible: false,
|
disableSubmit: false,
|
proOptions: [],
|
channelInfoList: [],
|
model: {},
|
labelCol: {
|
xs: { span: 24 },
|
sm: { span: 5 }
|
},
|
wrapperCol: {
|
xs: { span: 24 },
|
sm: { span: 16 }
|
},
|
confirmLoading: false,
|
validatorRules: {
|
prodId: [{ required: true, message: '请选择产品!' }],
|
batchType: [{ required: true, message: '请选择鉴定类型!' }],
|
batchCode: [{ required: true, message: '批次号不能为空!' }]
|
|
},
|
url: {
|
add: '/lims/testing/batch/add',
|
edit: '/lims/testing/batch/edit',
|
queryById: '/lims/testing/batch/queryById'
|
}
|
}
|
},
|
methods: {
|
add() {
|
this.visible = true
|
this.initOptions()
|
|
},
|
edit(record) {
|
this.visible = true
|
|
},
|
close() {
|
this.$emit('close')
|
this.model = {}
|
this.channelInfoList = []
|
this.proOptions = []
|
this.visible = false
|
},
|
handleOk() {
|
console.info('handleOk')
|
this.submitForm()
|
},
|
submitCallback() {
|
this.$emit('ok')
|
this.visible = false
|
},
|
handleCancel() {
|
this.close()
|
},
|
//生成checkbox选项
|
createOptions(num){
|
let array = []
|
for (let i = 1; i <= num; i++) {
|
array.push(i +'')
|
}
|
return array;
|
},
|
//选择checkbox
|
onCbChange(item,checked){
|
console.info(item)
|
console.info(checked)
|
|
},
|
|
//选择批次类型
|
batchTypeChange(value) {
|
if (value) {
|
this.generateBatchCode(value)
|
}
|
|
},
|
//选择产品
|
proChange(value) {
|
console.info(value)
|
this.queryProModel(value)
|
},
|
submitForm() {
|
this.$refs.form.validate(valid => {
|
if (valid) {
|
console.info('valid')
|
//校验通道信息是否填写正确
|
let flag = false
|
console.info(this.channelInfoList)
|
for (let i = 0; i <this.channelInfoList.length ; i++) {
|
let item = this.channelInfoList[i]
|
if(item.channelNum){
|
this.channelInfoList[i].channels = item.channelNum.join(",")
|
if(item.sampleNum && item.channels){
|
flag = true
|
}
|
}
|
|
}
|
console.info(flag)
|
//校验通过
|
if(flag){
|
this.$message.success("校验通过")
|
this.model.channelInfoList = this.channelInfoList
|
this.handleAdd()
|
}else{
|
this.$message.warning("请检查通道信息是否填写正确")
|
}
|
}
|
})
|
},
|
//添加
|
handleAdd(){
|
this.confirmLoading = true
|
postAction(this.url.add,this.model).then(res=>{
|
console.info(res)
|
if(res.success){
|
this.$message.success(res.message)
|
this.close()
|
this.submitCallback()
|
}else {
|
this.$message.error(res.message)
|
}
|
}).finally(() => {
|
this.confirmLoading = false;
|
})
|
|
},
|
|
//生成批次号
|
generateBatchCode(value) {
|
const date = new Date()
|
const year = date.getFullYear()
|
let month = date.getMonth() + 1
|
let day = date.getDate()
|
var hour = date.getHours() // 获取小时
|
var minute = date.getMinutes() // 获取分钟
|
var second = date.getSeconds() // 获取秒
|
if (month < 10) month = '0' + month
|
if (day < 10) day = '0' + day
|
if (hour < 10) hour = '0' + hour
|
if (minute < 10) minute = '0' + minute
|
if (second < 10) second = '0' + second
|
|
let batchCode = value + '' + year + month + day + hour + minute + second
|
|
this.model.batchCode = batchCode
|
|
},
|
initOptions() {
|
//产品列表
|
queryProductList({ 'pageNo': 1, 'pageSize': 1000 }).then(res => {
|
if (res.success) {
|
let result = res.result.records
|
this.proOptions = []
|
if (result) {
|
result.forEach(item => {
|
this.proOptions.push({ 'text': item.name, 'value': item.id })
|
})
|
}
|
}
|
|
})
|
|
},
|
queryProModel(proId) {
|
if(!proId){
|
|
return false
|
}
|
//产品型号列表
|
queryProModelList({ 'prodId': proId, 'pageNo': 1, 'pageSize': 1000 }).then(res => {
|
console.info(res)
|
if (res.success) {
|
this.channelInfoList = []
|
res.result.records.forEach(item => {
|
let channel = { modelId:item.id,modelName:item.modelName, num: item.channelNum,modelCode:item.modelCode }
|
this.channelInfoList.push(channel)
|
})
|
}
|
})
|
}
|
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|