Step3.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
  3. <a-table
  4. :columns="columns"
  5. :dataSource="model.list"
  6. :pagination="false"
  7. >
  8. <template slot="yangpinKeyId" slot-scope="text, record,index">
  9. <a-form-model-item :prop="'list.'+index+'.yangpinKeyId'" :rules="validatorRules.yangpinKeyId">
  10. <a-select :disabled="formDisabled" v-model="record.yangpinKeyId" allowClear :dropdownMatchSelectWidth="false">
  11. <a-select-option v-for="d in yangpins" :key="d.sampleName">
  12. {{ d.sampleName }}
  13. </a-select-option>
  14. </a-select>
  15. </a-form-model-item>
  16. </template>
  17. <template slot="testItems" slot-scope="text, record,index">
  18. <a-form-model-item :prop="'list.'+index+'.testItems'" :rules="validatorRules.testItems">
  19. <a-input :disabled="formDisabled" v-model="record.testItems" />
  20. </a-form-model-item>
  21. </template>
  22. <template slot="standardRequirement" slot-scope="text, record,index">
  23. <a-form-model-item :prop="'list.'+index+'.standardRequirement'" :rules="validatorRules.standardRequirement">
  24. <!-- <j-multi-select-tag :disabled="formDisabled" v-model="record.standardRequirement" :dropdownMatchSelectWidth="false" dictCode="itdm_weituo_yiju,name,name" /> -->
  25. <!-- 为了解决下拉框显示不全的问题,原来的没有对应参数配置 -->
  26. <a-select :disabled="formDisabled" v-model="record.standardRequirement" allowClear :dropdownMatchSelectWidth="false">
  27. <a-select-option v-for="(item, index) in yijuLists" :key="index">
  28. {{ item.name }}
  29. </a-select-option>
  30. </a-select>
  31. </a-form-model-item>
  32. </template>
  33. <template slot="judgementBasis" slot-scope="text, record,index">
  34. <a-form-model-item :prop="'list.'+index+'.judgementBasis'" :rules="validatorRules.judgementBasis">
  35. <a-input :disabled="formDisabled" v-model="record.judgementBasis" />
  36. </a-form-model-item>
  37. </template>
  38. <template slot="yijufile" slot-scope="text, record,index">
  39. <a-form-model-item :prop="'list.'+index+'.yijufile'" :rules="validatorRules.yijufile">
  40. <a-input :disabled="formDisabled" v-model="record.yijufile" />
  41. </a-form-model-item>
  42. </template>
  43. <template slot="beizhu" slot-scope="text, record,index">
  44. <a-form-model-item :prop="'list.'+index+'.beizhu'">
  45. <a-input :disabled="formDisabled" v-model="record.beizhu" />
  46. </a-form-model-item>
  47. </template>
  48. <template slot="operation" slot-scope="text, record">
  49. <span>
  50. <a-popconfirm :disabled="formDisabled" title="是否要删除此行?" @confirm="remove(record.key)">
  51. <a>删除</a>
  52. </a-popconfirm>
  53. </span>
  54. </template>
  55. </a-table>
  56. <a-button :disabled="formDisabled" style="width: 100%; margin-top: 16px; margin-bottom: 8px" type="dashed"
  57. icon="plus"
  58. @click="newMember">
  59. 新增试验信息
  60. </a-button>
  61. <a-form-item class="buttonAll">
  62. <div class="all">
  63. <a-button style="margin-left: 8px" @click="prevStep" class="next">上一步</a-button>
  64. <a-button v-if="!disabled" type="primary" style="margin-left: 8px" @click="submitForm" class="next">提交
  65. </a-button>
  66. </div>
  67. </a-form-item>
  68. </a-form-model>
  69. </template>
  70. <script>
  71. import {getAction} from '@/api/manage'
  72. export default {
  73. name: 'step3',
  74. props: {
  75. //表单禁用
  76. disabled: {
  77. type: Boolean,
  78. default: false,
  79. required: false
  80. }
  81. },
  82. data() {
  83. return {
  84. yangpins: {},
  85. count: 1,
  86. model: {
  87. list: []
  88. },
  89. description: '高级表单常见于一次性输入和提交大批量数据的场景。',
  90. loading: false,
  91. validatorRules: {
  92. yangpinKeyId: [
  93. { required: true, message: '请选择样品!' }
  94. ],
  95. testItems: [
  96. { required: true, message: '请输入检测标准!' }
  97. ]
  98. },
  99. yijuLists: [],
  100. // table
  101. columns: [
  102. {
  103. title: '样品名称',
  104. dataIndex: 'yangpinKeyId',
  105. key: 'yangpinKeyId',
  106. align: 'center',
  107. width: '15%',
  108. scopedSlots: { customRender: 'yangpinKeyId' }
  109. },
  110. {
  111. title: '检测项目',
  112. dataIndex: 'testItems',
  113. key: 'testItems',
  114. align: 'center',
  115. width: '15%',
  116. scopedSlots: { customRender: 'testItems' }
  117. },
  118. {
  119. title: '检测依据',
  120. dataIndex: 'standardRequirement',
  121. key: 'standardRequirement',
  122. align: 'center',
  123. width: '20%',
  124. scopedSlots: { customRender: 'standardRequirement' }
  125. },
  126. {
  127. title: '判定依据',
  128. dataIndex: 'judgementBasis',
  129. key: 'judgementBasis',
  130. align: 'center',
  131. width: '25%',
  132. scopedSlots: { customRender: 'judgementBasis' }
  133. },
  134. {
  135. title: '检测依据文件',
  136. dataIndex: 'yijufile',
  137. key: 'yijufile',
  138. width: '15%',
  139. align: 'center',
  140. scopedSlots: { customRender: 'yijufile' }
  141. },
  142. {
  143. title: '备注',
  144. dataIndex: 'beizhu',
  145. key: 'beizhu',
  146. width: '15%',
  147. align: 'center',
  148. scopedSlots: { customRender: 'beizhu' }
  149. },
  150. {
  151. title: '操作',
  152. key: 'action',
  153. align: 'center',
  154. scopedSlots: { customRender: 'operation' }
  155. }
  156. ],
  157. data: []
  158. }
  159. },
  160. computed: {
  161. formDisabled() {
  162. return this.disabled
  163. }
  164. },
  165. created() {
  166. this.getYijuLists()
  167. const data = JSON.parse(sessionStorage.getItem('yangpinkz'))
  168. if (data != null) {
  169. this.model.list=data
  170. }else{
  171. this.newMember()
  172. }
  173. console.log(sessionStorage.getItem('yangpin'))
  174. const yangpins = JSON.parse(sessionStorage.getItem('yangpin'))
  175. if (yangpins != null) {
  176. this.yangpins = yangpins
  177. console.log(this.yangpins)
  178. }
  179. this.count = sessionStorage.getItem('count1') != null ? Number(sessionStorage.getItem('count1')) : 1
  180. },
  181. methods: {
  182. // 获取所有依据列表
  183. getYijuLists(){
  184. getAction('/weituoyiju/itdmWeituoYiju/getAllList').then((res) => {
  185. // console.log(res)
  186. this.yijuLists = res.result
  187. })
  188. },
  189. newMember() {
  190. this.model.list.push({
  191. key: this.count + '',
  192. yangpinKeyId: '',
  193. testItems: '',
  194. standardRequirement: '',
  195. judgementBasis: '',
  196. yijufile: '',
  197. beizhu: '',
  198. editable: true,
  199. isNew: true
  200. })
  201. this.count++
  202. sessionStorage.setItem('count1', this.count)
  203. },
  204. remove(key) {
  205. const newData = this.model.list.filter(item => item.key !== key)
  206. this.model.list = newData
  207. },
  208. saveRow(key) {
  209. let target = this.model.list.filter(item => item.key === key)[0]
  210. target.editable = false
  211. target.isNew = false
  212. },
  213. handleChange(value, key, column) {
  214. const newData = [...this.model.list]
  215. const target = newData.filter(item => key === item.key)[0]
  216. if (target) {
  217. target[column] = value
  218. this.model.list = newData
  219. }
  220. },
  221. submitForm() {
  222. sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
  223. this.$refs.form.validate(valid => {
  224. if (valid) {
  225. this.$emit('submitForm')
  226. }
  227. })
  228. },
  229. prevStep() {
  230. sessionStorage.setItem('yangpinkz', JSON.stringify(this.model.list))
  231. this.$emit('prevStep')
  232. }
  233. }
  234. }
  235. </script>
  236. <style lang="less" scoped>
  237. .card {
  238. margin-bottom: 24px;
  239. }
  240. .next {
  241. width: 35%;
  242. margin-left: 20px;
  243. margin-right: 20px;
  244. margin-top: 20px;
  245. }
  246. .buttonAll {
  247. width: 100%;
  248. align-items: center;
  249. justify-content: center;
  250. }
  251. .all {
  252. width: 100%;
  253. display: flex;
  254. align-items: center;
  255. justify-content: center;
  256. }
  257. </style>