BudgetReplyModal.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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="8">
  15. <a-form-item label="登记人" :labelCol="labelCol" :wrapperCol="wrapperCol">
  16. <j-popup
  17. v-decorator="['registerPerson', validatorRules.registerPerson]"
  18. :trigger-change="true"
  19. org-fields="realname,depart_name"
  20. dest-fields="registerPerson,registerDept"
  21. code="user_dept"
  22. @callback="popupCallback"/>
  23. </a-form-item>
  24. </a-col>
  25. <a-col :span="8">
  26. <a-form-item label="登记部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
  27. <a-input :disabled="true" v-decorator="[ 'registerDept', validatorRules.registerDept]" placeholder="请输入登记部门"></a-input>
  28. </a-form-item>
  29. </a-col>
  30. <a-col :span="8">
  31. <a-form-item label="登记日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  32. <j-date placeholder="请选择登记日期" v-decorator="[ 'registerDate', validatorRules.registerDate]" :trigger-change="true" style="width: 100%"/>
  33. </a-form-item>
  34. </a-col>
  35. <a-col :span="8">
  36. <a-form-item label="预算年度" :labelCol="labelCol" :wrapperCol="wrapperCol">
  37. <a-date-picker
  38. mode="year"
  39. v-decorator="['budgetYear', validatorRules.budgetYear]"
  40. placeholder="请输入年份"
  41. format="YYYY"
  42. style="width: 200px"
  43. :open="yearShowOne"
  44. @openChange="openChangeOne"
  45. @panelChange="panelChangeOne"/>
  46. </a-form-item>
  47. </a-col>
  48. <a-col :span="8">
  49. <a-form-item label="预算总额" :labelCol="labelCol" :wrapperCol="wrapperCol">
  50. <a-input v-decorator="[ 'budgetTotal', validatorRules.budgetTotal]" placeholder="请输入预算总额"></a-input>
  51. </a-form-item>
  52. </a-col>
  53. <a-col :span="24">
  54. <a-form-item label="附件" :labelCol="labelCol" :wrapperCol="wrapperCol">
  55. <j-upload v-decorator="['file', validatorRules.file]" :trigger-change="true"></j-upload>
  56. </a-form-item>
  57. </a-col>
  58. </a-row>
  59. </a-form>
  60. <!-- 子表单区域 -->
  61. <a-tabs v-model="activeKey" @change="handleChangeTabs">
  62. <a-tab-pane tab="预算批复管理子表" :key="refKeys[0]" :forceRender="true">
  63. <j-editable-table
  64. :ref="refKeys[0]"
  65. :loading="budgetReplyDetailTable.loading"
  66. :columns="budgetReplyDetailTable.columns"
  67. :dataSource="budgetReplyDetailTable.dataSource"
  68. :maxHeight="300"
  69. :rowNumber="true"
  70. :rowSelection="true"
  71. :actionButton="true"/>
  72. </a-tab-pane>
  73. </a-tabs>
  74. </a-spin>
  75. </a-modal>
  76. </template>
  77. <script>
  78. import moment from 'moment'
  79. import pick from 'lodash.pick'
  80. import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
  81. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  82. import { validateDuplicateValue } from '@/utils/util'
  83. import JDate from '@/components/jeecg/JDate'
  84. import JUpload from '@/components/jeecg/JUpload'
  85. export default {
  86. name: 'BudgetReplyModal',
  87. mixins: [JEditableTableMixin],
  88. components: {
  89. JDate,
  90. JUpload,
  91. },
  92. data() {
  93. return {
  94. yearShowOne: false,
  95. labelCol: {
  96. span: 6
  97. },
  98. wrapperCol: {
  99. span: 16
  100. },
  101. labelCol2: {
  102. span: 3
  103. },
  104. wrapperCol2: {
  105. span: 20
  106. },
  107. // 新增时子表默认添加几行空数据
  108. addDefaultRowNum: 1,
  109. validatorRules: {
  110. registerPerson: {rules: [
  111. {required: true, message: '请输入登记人!'},
  112. ]},
  113. registerDept: {rules: [
  114. ]},
  115. registerDate: {rules: [
  116. {required: true, message: '请输入登记日期!'},
  117. ]},
  118. budgetYear: {rules: [
  119. {required: true, message: '请输入预算年度!'},
  120. ]},
  121. budgetTotal: {rules: [
  122. ]},
  123. file: {rules: [
  124. ]},
  125. },
  126. refKeys: ['budgetReplyDetail', ],
  127. tableKeys:['budgetReplyDetail', ],
  128. activeKey: 'budgetReplyDetail',
  129. // 预算批复管理子表
  130. budgetReplyDetailTable: {
  131. loading: false,
  132. dataSource: [],
  133. columns: [
  134. {
  135. title: '部门',
  136. key: 'department',
  137. type: FormTypes.input,
  138. width:"200px",
  139. placeholder: '请输入${title}',
  140. defaultValue: '',
  141. },
  142. {
  143. title: '费用资金类别',
  144. key: 'costFundType',
  145. type: FormTypes.input,
  146. width:"200px",
  147. placeholder: '请输入${title}',
  148. defaultValue: '',
  149. },
  150. {
  151. title: '预算资金类别',
  152. key: 'budgetFundType',
  153. type: FormTypes.input,
  154. width:"200px",
  155. placeholder: '请输入${title}',
  156. defaultValue: '',
  157. },
  158. {
  159. title: '预算资金名称',
  160. key: 'budgetFundName',
  161. type: FormTypes.input,
  162. width:"200px",
  163. placeholder: '请输入${title}',
  164. defaultValue: '',
  165. },
  166. {
  167. title: '预算资金构成',
  168. key: 'budgetFundPose',
  169. type: FormTypes.input,
  170. width:"200px",
  171. placeholder: '请输入${title}',
  172. defaultValue: '',
  173. },
  174. {
  175. title: '预算资金来源',
  176. key: 'budgetFundSource',
  177. type: FormTypes.input,
  178. width:"200px",
  179. placeholder: '请输入${title}',
  180. defaultValue: '',
  181. },
  182. {
  183. title: '明细内容',
  184. key: 'detailContent',
  185. type: FormTypes.input,
  186. width:"200px",
  187. placeholder: '请输入${title}',
  188. defaultValue: '',
  189. },
  190. {
  191. title: '明细金额',
  192. key: 'detailMoney',
  193. type: FormTypes.input,
  194. width:"200px",
  195. placeholder: '请输入${title}',
  196. defaultValue: '',
  197. },
  198. {
  199. title: '拨付方式',
  200. key: 'paymentMethod',
  201. type: FormTypes.input,
  202. width:"200px",
  203. placeholder: '请输入${title}',
  204. defaultValue: '',
  205. },
  206. {
  207. title: '采购方式',
  208. key: 'purchaseMethod',
  209. type: FormTypes.input,
  210. width:"200px",
  211. placeholder: '请输入${title}',
  212. defaultValue: '',
  213. },
  214. {
  215. title: '采购编号',
  216. key: 'purchaseNum',
  217. type: FormTypes.input,
  218. width:"200px",
  219. placeholder: '请输入${title}',
  220. defaultValue: '',
  221. },
  222. {
  223. title: '备注',
  224. key: 'remark',
  225. type: FormTypes.input,
  226. width:"200px",
  227. placeholder: '请输入${title}',
  228. defaultValue: '',
  229. },
  230. ]
  231. },
  232. url: {
  233. add: "/oa/budgetReply/add",
  234. edit: "/oa/budgetReply/edit",
  235. budgetReplyDetail: {
  236. list: '/oa/budgetReply/queryBudgetReplyDetailByMainId'
  237. },
  238. }
  239. }
  240. },
  241. methods: {
  242. getAllTable() {
  243. let values = this.tableKeys.map(key => getRefPromise(this, key))
  244. return Promise.all(values)
  245. },
  246. /** 调用完edit()方法之后会自动调用此方法 */
  247. editAfter() {
  248. if(this.model.budgetYear){
  249. this.model.budgetYear = moment(this.model.budgetYear);
  250. }
  251. let fieldval = pick(this.model,'registerPerson','registerDept','registerDate','budgetYear','budgetTotal','file')
  252. this.$nextTick(() => {
  253. this.form.setFieldsValue(fieldval)
  254. })
  255. // 加载子表数据
  256. if (this.model.id) {
  257. let params = { id: this.model.id }
  258. this.requestSubTableData(this.url.budgetReplyDetail.list, params, this.budgetReplyDetailTable)
  259. }
  260. },
  261. /** 整理成formData */
  262. classifyIntoFormData(allValues) {
  263. let main = Object.assign(this.model, allValues.formValue)
  264. return {
  265. ...main, // 展开
  266. budgetReplyDetailList: allValues.tablesValue[0].values,
  267. }
  268. },
  269. validateError(msg){
  270. this.$message.error(msg)
  271. },
  272. popupCallback(row){
  273. this.form.setFieldsValue(pick(row,'registerPerson','registerDept','registerDate','budgetYear','budgetTotal','file'))
  274. },
  275. // 弹出日历和关闭日历的回调
  276. openChangeOne(status) {
  277. if (status) {
  278. this.yearShowOne = true;
  279. }
  280. },
  281. // 得到年份选择器的值
  282. panelChangeOne(value) {
  283. this.yearShowOne = false;
  284. this.$nextTick(() => {
  285. this.form.setFieldsValue({
  286. budgetYear: value,
  287. });
  288. });
  289. },
  290. }
  291. }
  292. </script>
  293. <style scoped>
  294. </style>