MaterialInModal.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="1200"
  5. :visible="visible"
  6. :maskClosable="false"
  7. :confirmLoading="confirmLoading"
  8. @ok="handleOk"
  9. @cancel="handleCancel">
  10. <a-spin :spinning="confirmLoading">
  11. <!-- 主表单区域 -->
  12. <a-form :form="form">
  13. <a-row>
  14. <a-col :span="12">
  15. <a-form-item label="入库人" :labelCol="labelCol" :wrapperCol="wrapperCol">
  16. <j-popup
  17. v-decorator="['operator', validatorRules.operator]"
  18. placeholder="请选择入库人"
  19. :trigger-change="true"
  20. org-fields="realname,depart_name"
  21. dest-fields="operator,operatorDept"
  22. code="user_dept"
  23. @callback="popupCallback"/>
  24. </a-form-item>
  25. </a-col>
  26. <a-col :span="12">
  27. <a-form-item label="入库部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
  28. <a-input v-decorator="[ 'operatorDept', validatorRules.operatorDept]" placeholder="请输入入库部门" disabled></a-input>
  29. </a-form-item>
  30. </a-col>
  31. <a-col :span="12">
  32. <a-form-item label="入库日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  33. <j-date placeholder="请选择入库日期" v-decorator="[ 'operateDate', validatorRules.operateDate]" :trigger-change="true" style="width: 100%"/>
  34. </a-form-item>
  35. </a-col>
  36. <a-col :span="24">
  37. <a-form-item label="备注" :labelCol="labelCol2" :wrapperCol="wrapperCol2">
  38. <a-textarea v-decorator="['remark', validatorRules.remark]" rows="4" placeholder="请输入备注"/>
  39. </a-form-item>
  40. </a-col>
  41. <a-col :span="12">
  42. <a-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
  43. <j-upload v-decorator="['attachment', validatorRules.attachment]" :trigger-change="true"></j-upload>
  44. </a-form-item>
  45. </a-col>
  46. </a-row>
  47. </a-form>
  48. <!-- 子表单区域 -->
  49. <a-tabs v-model="activeKey" @change="handleChangeTabs">
  50. <a-tab-pane tab="物料入库明细" :key="refKeys[0]" :forceRender="true">
  51. <j-editable-table
  52. :ref="refKeys[0]"
  53. :loading="materialInDetailTable.loading"
  54. :columns="materialInDetailTable.columns"
  55. :dataSource="materialInDetailTable.dataSource"
  56. :maxHeight="300"
  57. :rowNumber="true"
  58. :rowSelection="true"
  59. :actionButton="true"/>
  60. </a-tab-pane>
  61. </a-tabs>
  62. </a-spin>
  63. </a-modal>
  64. </template>
  65. <script>
  66. import pick from 'lodash.pick'
  67. import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
  68. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  69. import { validateDuplicateValue } from '@/utils/util'
  70. import JDate from '@/components/jeecg/JDate'
  71. import JUpload from '@/components/jeecg/JUpload'
  72. export default {
  73. name: 'MaterialInModal',
  74. mixins: [JEditableTableMixin],
  75. components: {
  76. JDate,
  77. JUpload,
  78. },
  79. data() {
  80. return {
  81. labelCol: {
  82. span: 6
  83. },
  84. wrapperCol: {
  85. span: 16
  86. },
  87. labelCol2: {
  88. span: 3
  89. },
  90. wrapperCol2: {
  91. span: 20
  92. },
  93. // 新增时子表默认添加几行空数据
  94. addDefaultRowNum: 1,
  95. validatorRules: {
  96. operator: {rules: [
  97. {required: true, message: '请选择入库人 !'},
  98. ]},
  99. operatorDept: {rules: [
  100. ]},
  101. operateDate: {rules: [
  102. {required: true, message: '请选择入库日期 !'},
  103. ]},
  104. remark: {rules: [
  105. ]},
  106. attachment: {rules: [
  107. ]},
  108. },
  109. refKeys: ['materialInDetail', ],
  110. tableKeys:['materialInDetail', ],
  111. activeKey: 'materialInDetail',
  112. // 物料入库明细
  113. materialInDetailTable: {
  114. loading: false,
  115. dataSource: [],
  116. columns: [
  117. {
  118. title: '物料名称',
  119. key: 'materialName',
  120. type: FormTypes.popup,
  121. popupCode:"sel_material",
  122. destFields:"materialName,brand,category,model,unit,cdMaterialId",
  123. orgFieldse:"material_name,brand,category,model,unit,id",
  124. width:"200px",
  125. placeholder: '请选择物料',
  126. defaultValue: '',
  127. validateRules: [{ required: true, message: '${title}不能为空' }]
  128. },
  129. {
  130. title: '品牌',
  131. key: 'brand',
  132. type: FormTypes.input,
  133. width:"200px",
  134. placeholder: '请输入${title}',
  135. defaultValue: '',
  136. disabled: true
  137. },
  138. {
  139. title: '类别',
  140. key: 'category',
  141. type: FormTypes.input,
  142. width:"200px",
  143. placeholder: '请输入${title}',
  144. defaultValue: '',
  145. disabled: true
  146. },
  147. {
  148. title: '规格型号',
  149. key: 'model',
  150. type: FormTypes.input,
  151. width:"200px",
  152. placeholder: '请输入${title}',
  153. defaultValue: '',
  154. disabled: true
  155. },
  156. {
  157. title: '计量单位',
  158. key: 'unit',
  159. type: FormTypes.input,
  160. width:"200px",
  161. placeholder: '请输入${title}',
  162. defaultValue: '',
  163. disabled: true
  164. },
  165. {
  166. title: '入库数量',
  167. key: 'quantity',
  168. type: FormTypes.input,
  169. width:"200px",
  170. placeholder: '请输入${title}',
  171. defaultValue: '',
  172. },
  173. {
  174. title: 'ID',
  175. key: 'cdMaterialId',
  176. type: FormTypes.hidden,
  177. width:"200px",
  178. defaultValue: '',
  179. },
  180. ]
  181. },
  182. url: {
  183. add: "/oa/materialIn/add",
  184. edit: "/oa/materialIn/edit",
  185. materialInDetail: {
  186. list: '/oa/materialIn/queryMaterialInDetailByMainId'
  187. },
  188. }
  189. }
  190. },
  191. methods: {
  192. getAllTable() {
  193. let values = this.tableKeys.map(key => getRefPromise(this, key))
  194. return Promise.all(values)
  195. },
  196. /** 调用完edit()方法之后会自动调用此方法 */
  197. editAfter() {
  198. let fieldval = pick(this.model,'operator','operatorDept','operateDate','remark','attachment')
  199. this.$nextTick(() => {
  200. this.form.setFieldsValue(fieldval)
  201. })
  202. // 加载子表数据
  203. if (this.model.id) {
  204. let params = { id: this.model.id }
  205. this.requestSubTableData(this.url.materialInDetail.list, params, this.materialInDetailTable)
  206. }
  207. },
  208. /** 整理成formData */
  209. classifyIntoFormData(allValues) {
  210. let main = Object.assign(this.model, allValues.formValue)
  211. return {
  212. ...main, // 展开
  213. materialInDetailList: allValues.tablesValue[0].values,
  214. }
  215. },
  216. validateError(msg){
  217. this.$message.error(msg)
  218. },
  219. popupCallback(row){
  220. this.form.setFieldsValue(pick(row,'operator','operatorDept','operateDate','remark','attachment'))
  221. },
  222. }
  223. }
  224. </script>
  225. <style scoped>
  226. </style>