|
@@ -1,107 +1,84 @@
|
|
|
<template>
|
|
|
- <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
|
|
- <a-table
|
|
|
- :columns="columns"
|
|
|
- :dataSource="data"
|
|
|
- :pagination="false"
|
|
|
- >
|
|
|
+ <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
|
|
|
+ <a-table
|
|
|
+ :columns="columns"
|
|
|
+ :dataSource="model.list"
|
|
|
+ :pagination="false"
|
|
|
+ >
|
|
|
+
|
|
|
+
|
|
|
+ <template slot="yangpinKeyId" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'list.'+index+'.yangpinKeyId'" :rules="validatorRules.yangpinKeyId">
|
|
|
+ <a-select :disabled="formDisabled" v-model="record.yangpinKeyId">
|
|
|
+ <a-select-option v-for="d in yangpins" :key="d.sampleName">
|
|
|
+ {{ d.sampleName }}
|
|
|
+ </a-select-option>
|
|
|
+ </a-select>
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
|
|
|
+ <template slot="testItems" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'list.'+index+'.testItems'" :rules="validatorRules.testItems">
|
|
|
+ <a-input :disabled="formDisabled" v-model="record.testItems" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
|
|
|
- <template v-for="(col, i) in ['yangpinKeyId', 'testItems', 'standardRequirement','judgementBasis','yijufile','beizhu']"
|
|
|
- :slot="col" slot-scope="text, record">
|
|
|
|
|
|
+ <template slot="standardRequirement" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'list.'+index+'.standardRequirement'" :rules="validatorRules.standardRequirement">
|
|
|
+ <j-multi-select-tag :disabled="formDisabled" v-model="record.standardRequirement"
|
|
|
+ dictCode="itdm_weituo_yiju,name,name" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
|
|
|
- <a-select
|
|
|
- :disabled="formDisabled"
|
|
|
- :key="col"
|
|
|
- v-if="record.editable && col==='yangpinKeyId'"
|
|
|
- style="margin: -5px 0"
|
|
|
- :value="text"
|
|
|
- :placeholder="columns[i].title"
|
|
|
|
|
|
- @change="e => handleChange(e, record.key, col)">
|
|
|
+ <template slot="judgementBasis" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'list.'+index+'.judgementBasis'" :rules="validatorRules.judgementBasis">
|
|
|
+ <a-input :disabled="formDisabled" v-model="record.judgementBasis" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
+
|
|
|
+ <template slot="yijufile" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'list.'+index+'.yijufile'" :rules="validatorRules.yijufile">
|
|
|
+ <a-input :disabled="formDisabled" v-model="record.yijufile" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
|
|
|
- <a-select-option v-for="d in yangpins" :key="d.key">
|
|
|
- {{ d.sampleName }}
|
|
|
- </a-select-option>
|
|
|
- </a-select>
|
|
|
|
|
|
+ <template slot="beizhu" slot-scope="text, record,index">
|
|
|
+ <a-form-model-item :prop="'list.'+index+'.beizhu'">
|
|
|
+ <a-input :disabled="formDisabled" v-model="record.beizhu" />
|
|
|
+ </a-form-model-item>
|
|
|
+ </template>
|
|
|
|
|
|
- <a-input
|
|
|
- :disabled="formDisabled"
|
|
|
- :key="col"
|
|
|
- v-if="record.editable && col==='testItems'"
|
|
|
- style="margin: -5px 0"
|
|
|
- :value="text"
|
|
|
- :placeholder="columns[i].title"
|
|
|
- @change="e => handleChange(e.target.value, record.key, col)"></a-input>
|
|
|
-
|
|
|
-
|
|
|
- <j-multi-select-tag
|
|
|
- :disabled="formDisabled"
|
|
|
- :key="col"
|
|
|
- v-if="record.editable && col==='standardRequirement'"
|
|
|
- style="margin: -5px 0"
|
|
|
- :value="text"
|
|
|
- :placeholder="columns[i].title" @change="e=>handleChange(e, record.key, col)"
|
|
|
- dictCode="itdm_weituo_yiju,name,name" />
|
|
|
-
|
|
|
- <a-input
|
|
|
- :disabled="formDisabled"
|
|
|
- :key="col"
|
|
|
- v-if="record.editable && col==='judgementBasis'"
|
|
|
- style="margin: -5px 0"
|
|
|
- :value="text"
|
|
|
- :placeholder="columns[i].title"
|
|
|
- @change="e => handleChange(e.target.value, record.key, col)"></a-input>
|
|
|
-
|
|
|
-
|
|
|
- <a-input
|
|
|
- :disabled="formDisabled"
|
|
|
- :key="col"
|
|
|
- v-if="record.editable && col==='yijufile'"
|
|
|
- style="margin: -5px 0"
|
|
|
- :value="text"
|
|
|
- :placeholder="columns[i].title"
|
|
|
- @change="e => handleChange(e.target.value, record.key, col)"></a-input>
|
|
|
-
|
|
|
-
|
|
|
- <a-input
|
|
|
- :disabled="formDisabled"
|
|
|
- :key="col"
|
|
|
- v-if="record.editable && col==='beizhu'"
|
|
|
- style="margin: -5px 0"
|
|
|
- :value="text"
|
|
|
- :placeholder="columns[i].title"
|
|
|
- @change="e => handleChange(e.target.value, record.key, col)"></a-input>
|
|
|
-
|
|
|
-
|
|
|
- </template>
|
|
|
-
|
|
|
- <template slot="operation" slot-scope="text, record">
|
|
|
+
|
|
|
+ <template slot="operation" slot-scope="text, record">
|
|
|
<span>
|
|
|
- <a-popconfirm :disabled="formDisabled" title="是否要删除此行?" @confirm="remove(record.key)">
|
|
|
+ <a-popconfirm :disabled="formDisabled" title="是否要删除此行?" @confirm="remove(record.key)">
|
|
|
<a>删除</a>
|
|
|
</a-popconfirm>
|
|
|
</span>
|
|
|
- </template>
|
|
|
+ </template>
|
|
|
|
|
|
|
|
|
- </a-table>
|
|
|
- <a-button :disabled="formDisabled" style="width: 100%; margin-top: 16px; margin-bottom: 8px" type="dashed" icon="plus" @click="newMember">
|
|
|
- 新增试验信息
|
|
|
- </a-button>
|
|
|
+ </a-table>
|
|
|
+ <a-button :disabled="formDisabled" style="width: 100%; margin-top: 16px; margin-bottom: 8px" type="dashed"
|
|
|
+ icon="plus"
|
|
|
+ @click="newMember">
|
|
|
+ 新增试验信息
|
|
|
+ </a-button>
|
|
|
|
|
|
|
|
|
- <a-form-item class="buttonAll">
|
|
|
- <div class="all">
|
|
|
- <a-button style="margin-left: 8px" @click="prevStep" class="next">上一步</a-button>
|
|
|
- <a-button v-if="!disabled" type="primary" style="margin-left: 8px" @click="submitForm" class="next">提交</a-button>
|
|
|
- </div>
|
|
|
+ <a-form-item class="buttonAll">
|
|
|
+ <div class="all">
|
|
|
+ <a-button style="margin-left: 8px" @click="prevStep" class="next">上一步</a-button>
|
|
|
+ <a-button v-if="!disabled" type="primary" style="margin-left: 8px" @click="submitForm" class="next">提交
|
|
|
+ </a-button>
|
|
|
+ </div>
|
|
|
|
|
|
|
|
|
- </a-form-item>
|
|
|
- </a-form-model>
|
|
|
+ </a-form-item>
|
|
|
+ </a-form-model>
|
|
|
|
|
|
|
|
|
</template>
|
|
@@ -124,17 +101,27 @@ export default {
|
|
|
return {
|
|
|
yangpins: {},
|
|
|
count: 1,
|
|
|
- model: {},
|
|
|
+ model: {
|
|
|
+ list: []
|
|
|
+ },
|
|
|
description: '高级表单常见于一次性输入和提交大批量数据的场景。',
|
|
|
loading: false,
|
|
|
- validatorRules: {},
|
|
|
+ validatorRules: {
|
|
|
+ yangpinKeyId: [
|
|
|
+ { required: true, message: '请选择样品!' }
|
|
|
+ ],
|
|
|
+ testItems: [
|
|
|
+ { required: true, message: '请输入检测项目!' }
|
|
|
+ ]
|
|
|
+
|
|
|
+ },
|
|
|
// table
|
|
|
columns: [
|
|
|
{
|
|
|
title: '样品名称',
|
|
|
dataIndex: 'yangpinKeyId',
|
|
|
key: 'yangpinKeyId',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
width: '15%',
|
|
|
scopedSlots: { customRender: 'yangpinKeyId' }
|
|
|
},
|
|
@@ -142,7 +129,7 @@ export default {
|
|
|
title: '检测项目',
|
|
|
dataIndex: 'testItems',
|
|
|
key: 'testItems',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
width: '15%',
|
|
|
scopedSlots: { customRender: 'testItems' }
|
|
|
},
|
|
@@ -150,7 +137,7 @@ export default {
|
|
|
title: '检测依据',
|
|
|
dataIndex: 'standardRequirement',
|
|
|
key: 'standardRequirement',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
width: '20%',
|
|
|
scopedSlots: { customRender: 'standardRequirement' }
|
|
|
},
|
|
@@ -158,7 +145,7 @@ export default {
|
|
|
title: '判定依据',
|
|
|
dataIndex: 'judgementBasis',
|
|
|
key: 'judgementBasis',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
width: '25%',
|
|
|
scopedSlots: { customRender: 'judgementBasis' }
|
|
|
},
|
|
@@ -167,7 +154,7 @@ export default {
|
|
|
dataIndex: 'yijufile',
|
|
|
key: 'yijufile',
|
|
|
width: '15%',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
scopedSlots: { customRender: 'yijufile' }
|
|
|
},
|
|
|
|
|
@@ -176,13 +163,13 @@ export default {
|
|
|
dataIndex: 'beizhu',
|
|
|
key: 'beizhu',
|
|
|
width: '15%',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
scopedSlots: { customRender: 'beizhu' }
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
|
key: 'action',
|
|
|
- align:"center",
|
|
|
+ align: 'center',
|
|
|
scopedSlots: { customRender: 'operation' }
|
|
|
}
|
|
|
],
|
|
@@ -196,28 +183,16 @@ export default {
|
|
|
},
|
|
|
created() {
|
|
|
const data = JSON.parse(sessionStorage.getItem('yangpinkz'))
|
|
|
-
|
|
|
if (data != null) {
|
|
|
- for (let xx of data) {
|
|
|
- this.data.push({
|
|
|
- key: xx.key,
|
|
|
- yangpinKeyId: xx.yangpinKeyId,
|
|
|
- testItems: xx.testItems,
|
|
|
- standardRequirement: xx.standardRequirement,
|
|
|
- judgementBasis: xx.judgementBasis,
|
|
|
- yijufile: xx.yijufile,
|
|
|
- beizhu: xx.beizhu,
|
|
|
- editable: true,
|
|
|
- isNew: true
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
+ this.model.list=data
|
|
|
}
|
|
|
|
|
|
+ console.log(sessionStorage.getItem('yangpin'))
|
|
|
const yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
|
|
|
|
|
|
if (yangpins != null) {
|
|
|
this.yangpins = yangpins
|
|
|
+ console.log(this.yangpins)
|
|
|
}
|
|
|
|
|
|
this.count = sessionStorage.getItem('count1') != null ? Number(sessionStorage.getItem('count1')) : 1
|
|
@@ -226,13 +201,13 @@ export default {
|
|
|
methods: {
|
|
|
|
|
|
newMember() {
|
|
|
- this.data.push({
|
|
|
+ this.model.list.push({
|
|
|
key: this.count + '',
|
|
|
yangpinKeyId: '',
|
|
|
testItems: '',
|
|
|
standardRequirement: '',
|
|
|
judgementBasis: '',
|
|
|
- yijufile:'',
|
|
|
+ yijufile: '',
|
|
|
beizhu: '',
|
|
|
editable: true,
|
|
|
isNew: true
|
|
@@ -243,36 +218,37 @@ export default {
|
|
|
|
|
|
},
|
|
|
remove(key) {
|
|
|
- const newData = this.data.filter(item => item.key !== key)
|
|
|
- this.data = newData
|
|
|
+ const newData = this.model.list.filter(item => item.key !== key)
|
|
|
+ this.model.list = newData
|
|
|
},
|
|
|
saveRow(key) {
|
|
|
- let target = this.data.filter(item => item.key === key)[0]
|
|
|
+ let target = this.model.list.filter(item => item.key === key)[0]
|
|
|
target.editable = false
|
|
|
target.isNew = false
|
|
|
|
|
|
},
|
|
|
|
|
|
handleChange(value, key, column) {
|
|
|
- const newData = [...this.data]
|
|
|
+ const newData = [...this.model.list]
|
|
|
const target = newData.filter(item => key === item.key)[0]
|
|
|
if (target) {
|
|
|
target[column] = value
|
|
|
- this.data = newData
|
|
|
+ this.model.list = newData
|
|
|
}
|
|
|
},
|
|
|
submitForm() {
|
|
|
- sessionStorage.setItem('yangpinkz', JSON.stringify(this.data))
|
|
|
+ sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
|
|
|
|
|
|
- // this.$refs.form.validate(valid => {
|
|
|
- // if (valid) {
|
|
|
- this.$emit('submitForm')
|
|
|
- // }
|
|
|
- // })
|
|
|
+ this.$refs.form.validate(valid => {
|
|
|
+ if (valid) {
|
|
|
+
|
|
|
+ this.$emit('submitForm')
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
},
|
|
|
prevStep() {
|
|
|
- sessionStorage.setItem('yangpinkz', JSON.stringify(this.data))
|
|
|
+ sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
|
|
|
|
|
|
this.$emit('prevStep')
|
|
|
}
|
|
@@ -282,24 +258,27 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="less" scoped>
|
|
|
- .card {
|
|
|
- margin-bottom: 24px;
|
|
|
- }
|
|
|
- .next{
|
|
|
- width: 35%;
|
|
|
- margin-left: 20px;
|
|
|
- margin-right: 20px;
|
|
|
- margin-top: 20px;
|
|
|
- }
|
|
|
- .buttonAll{
|
|
|
- width: 100%;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- }
|
|
|
- .all{
|
|
|
- width: 100%;
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: center;
|
|
|
- }
|
|
|
+.card {
|
|
|
+ margin-bottom: 24px;
|
|
|
+}
|
|
|
+
|
|
|
+.next {
|
|
|
+ width: 35%;
|
|
|
+ margin-left: 20px;
|
|
|
+ margin-right: 20px;
|
|
|
+ margin-top: 20px;
|
|
|
+}
|
|
|
+
|
|
|
+.buttonAll {
|
|
|
+ width: 100%;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
+
|
|
|
+.all {
|
|
|
+ width: 100%;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+}
|
|
|
</style>
|