AssetInModal.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  1. <template>
  2. <a-modal
  3. :title="title"
  4. :width="1800"
  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="16">
  15. <a-form-item label="标题" :labelCol="{ span: 3 }" :wrapperCol="{ span: 21 }">
  16. <a-input v-decorator="[ 'title', validatorRules.title]" placeholder="请输入标题"></a-input>
  17. </a-form-item>
  18. </a-col>
  19. <a-col :span="8">
  20. <a-form-item label="单据号" :labelCol="labelCol" :wrapperCol="wrapperCol">
  21. <a-input v-decorator="[ 'inNo', validatorRules.inNo]" placeholder="请输入单据号"></a-input>
  22. </a-form-item>
  23. </a-col>
  24. <a-col :span="8">
  25. <a-form-item label="创建人" :labelCol="labelCol" :wrapperCol="wrapperCol">
  26. <a-input v-decorator="[ 'creater', validatorRules.creater]" placeholder="请输入创建人" disabled></a-input>
  27. </a-form-item>
  28. </a-col>
  29. <a-col :span="8">
  30. <a-form-item label="创建部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
  31. <a-input v-decorator="[ 'createrDept', validatorRules.createrDept]" placeholder="请输入创建部门" disabled></a-input>
  32. </a-form-item>
  33. </a-col>
  34. <a-col :span="8">
  35. <a-form-item label="创建时间" :labelCol="labelCol" :wrapperCol="wrapperCol">
  36. <j-date placeholder="请选择创建时间" v-decorator="[ 'createDate']" :showTime="true" dateFormat="YYYY-MM-DD HH:mm:ss" :trigger-change="true" style="width: 100%" disabled/>
  37. </a-form-item>
  38. </a-col>
  39. <a-col :span="8">
  40. <a-form-item label="入库人" :labelCol="labelCol" :wrapperCol="wrapperCol">
  41. <j-popup
  42. v-decorator="['operator', validatorRules.operator]"
  43. :trigger-change="true"
  44. org-fields="realname,depart_name"
  45. dest-fields="operator,operatorDept"
  46. code="user_dept"
  47. @callback="popupCallback"/>
  48. </a-form-item>
  49. </a-col>
  50. <a-col :span="8">
  51. <a-form-item label="入库部门" :labelCol="labelCol" :wrapperCol="wrapperCol">
  52. <a-input v-decorator="[ 'operatorDept', validatorRules.operatorDept]" placeholder="请输入入库部门" disabled></a-input>
  53. </a-form-item>
  54. </a-col>
  55. <a-col :span="8">
  56. <a-form-item label="入库日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
  57. <j-date placeholder="请选择入库日期" v-decorator="[ 'operatorDate', validatorRules.operatorDate]" :showTime="true" dateFormat="YYYY-MM-DD HH:mm:ss" :trigger-change="true" style="width: 100%"/>
  58. </a-form-item>
  59. </a-col>
  60. </a-row>
  61. </a-form>
  62. <!-- 子表单区域 -->
  63. <a-tabs v-model="activeKey" @change="handleChangeTabs">
  64. <a-tab-pane tab="固定资产入库明细" :key="refKeys[0]" :forceRender="true">
  65. <j-editable-table
  66. :ref="refKeys[0]"
  67. :loading="assetInDetailTable.loading"
  68. :columns="assetInDetailTable.columns"
  69. :dataSource="assetInDetailTable.dataSource"
  70. :maxHeight="300"
  71. :rowNumber="false"
  72. :rowSelection="true"
  73. :actionButton="true"/>
  74. </a-tab-pane>
  75. </a-tabs>
  76. </a-spin>
  77. </a-modal>
  78. </template>
  79. <script>
  80. import pick from 'lodash.pick'
  81. import { FormTypes,getRefPromise } from '@/utils/JEditableTableUtil'
  82. import { JEditableTableMixin } from '@/mixins/JEditableTableMixin'
  83. import { validateDuplicateValue } from '@/utils/util'
  84. import JDate from '@/components/jeecg/JDate'
  85. import moment from 'moment'
  86. export default {
  87. name: 'AssetInModal',
  88. mixins: [JEditableTableMixin],
  89. components: {
  90. JDate,
  91. },
  92. data() {
  93. return {
  94. labelCol: {
  95. span: 6
  96. },
  97. wrapperCol: {
  98. span: 16
  99. },
  100. labelCol2: {
  101. span: 3
  102. },
  103. wrapperCol2: {
  104. span: 20
  105. },
  106. // 新增时子表默认添加几行空数据
  107. addDefaultRowNum: 1,
  108. validatorRules: {
  109. title: {rules: [
  110. ]},
  111. inNo: {rules: [
  112. ]},
  113. creater: {rules: [
  114. ]},
  115. createrDept: {rules: [
  116. ]},
  117. operator: {rules: [
  118. {required: true, message: '请选择入库人 !'},
  119. ]},
  120. operatorDept: {rules: [
  121. ]},
  122. operatorDate: {rules: [
  123. {required: true, message: '请选择入库日期 !'},
  124. ]},
  125. },
  126. refKeys: ['assetInDetail', ],
  127. tableKeys:['assetInDetail', ],
  128. activeKey: 'assetInDetail',
  129. // 固定资产入库明细
  130. assetInDetailTable: {
  131. loading: false,
  132. dataSource: [],
  133. columns: [
  134. {
  135. title: '资产编号',
  136. key: 'assetNumber',
  137. type: FormTypes.input,
  138. width:"200px",
  139. placeholder: '请输入${title}',
  140. defaultValue: '',
  141. },
  142. {
  143. title: '资产名称',
  144. key: 'assetName',
  145. type: FormTypes.input,
  146. width:"200px",
  147. placeholder: '请输入${title}',
  148. defaultValue: '',
  149. },
  150. {
  151. title: '资产类别',
  152. key: 'assetsCategory',
  153. type: FormTypes.input,
  154. width:"200px",
  155. type: FormTypes.select,
  156. options: [ // 下拉选项
  157. { title: '办公家具', value: '办公家具' },
  158. { title: '办公设备', value: '办公设备' },
  159. { title: '不动产', value: '不动产' },
  160. { title: '车辆', value: '车辆' },
  161. { title: '其他', value: '其他' },
  162. ],
  163. },
  164. {
  165. title: '品牌',
  166. key: 'brand',
  167. type: FormTypes.input,
  168. width:"200px",
  169. placeholder: '请输入${title}',
  170. defaultValue: '',
  171. },
  172. {
  173. title: '单位名称',
  174. key: 'unitName',
  175. type: FormTypes.input,
  176. width:"200px",
  177. placeholder: '请输入${title}',
  178. defaultValue: '',
  179. },
  180. {
  181. title: '规格型号',
  182. key: 'model',
  183. type: FormTypes.input,
  184. width:"200px",
  185. placeholder: '请输入${title}',
  186. defaultValue: '',
  187. },
  188. {
  189. title: '计量单位',
  190. key: 'unit',
  191. type: FormTypes.input,
  192. width:"200px",
  193. placeholder: '请输入${title}',
  194. defaultValue: '',
  195. },
  196. {
  197. title: '数量',
  198. key: 'quantity',
  199. type: FormTypes.input,
  200. width:"200px",
  201. placeholder: '请输入${title}',
  202. defaultValue: '',
  203. },
  204. {
  205. title: '金额',
  206. key: 'amount',
  207. type: FormTypes.input,
  208. width:"200px",
  209. placeholder: '请输入${title}',
  210. defaultValue: '',
  211. validateRules: [
  212. { pattern: /^\d+(\.\d{1,2})?$/, message: '请输入金额(保留两位小数)' },
  213. ]
  214. },
  215. {
  216. title: '使用年限',
  217. key: 'exp',
  218. type: FormTypes.input,
  219. width:"200px",
  220. placeholder: '请输入${title}',
  221. defaultValue: '',
  222. },
  223. {
  224. title: '购置日期',
  225. key: 'purhcaseDate',
  226. type: FormTypes.date,
  227. width:"200px",
  228. placeholder: '请输入${title}',
  229. defaultValue: '',
  230. },
  231. {
  232. title: '入库日期',
  233. key: 'inDate',
  234. type: FormTypes.date,
  235. width:"200px",
  236. placeholder: '请输入${title}',
  237. defaultValue: '',
  238. },
  239. {
  240. title: '存放地点',
  241. key: 'place',
  242. type: FormTypes.input,
  243. width:"200px",
  244. placeholder: '请输入${title}',
  245. defaultValue: '',
  246. },
  247. {
  248. title: '使用人',
  249. key: 'user',
  250. type: FormTypes.popup,
  251. popupCode:"user_dept",
  252. destFields:"user,userDept,state",
  253. orgFieldse:"realname,depart_name,state",
  254. width:"200px",
  255. placeholder: '请输入${title}',
  256. defaultValue: '',
  257. },
  258. {
  259. title: '使用部门',
  260. key: 'userDept',
  261. type: FormTypes.input,
  262. width:"200px",
  263. placeholder: '请输入${title}',
  264. defaultValue: '',
  265. disabled:true
  266. },
  267. {
  268. title: '资产状态',
  269. key: 'state',
  270. type: FormTypes.input,
  271. width:"200px",
  272. placeholder: '请输入${title}',
  273. defaultValue: '闲置',
  274. disabled:true
  275. },
  276. {
  277. title: '备注',
  278. key: 'remark',
  279. type: FormTypes.input,
  280. width:"200px",
  281. placeholder: '请输入${title}',
  282. defaultValue: '',
  283. },
  284. {
  285. title: '附件',
  286. key: 'attachment',
  287. type: FormTypes.file,
  288. token:true,
  289. responseName:"message",
  290. width:"200px",
  291. placeholder: '请选择文件',
  292. defaultValue: '',
  293. },
  294. ]
  295. },
  296. url: {
  297. add: "/oa/assetIn/add",
  298. edit: "/oa/assetIn/edit",
  299. assetInDetail: {
  300. list: '/oa/assetIn/queryAssetInDetailByMainId'
  301. },
  302. }
  303. }
  304. },
  305. methods: {
  306. init(){
  307. this.$nextTick(() => {
  308. this.form.setFieldsValue({
  309. creater: this.$store.getters.userInfo.realname,
  310. createrDept: this.$store.getters.userInfo.deptName,
  311. createDate: moment().format('YYYY-MM-DD HH:mm:ss')
  312. })
  313. })
  314. },
  315. getAllTable() {
  316. let values = this.tableKeys.map(key => getRefPromise(this, key))
  317. return Promise.all(values)
  318. },
  319. /** 调用完edit()方法之后会自动调用此方法 */
  320. editAfter() {
  321. let fieldval = pick(this.model,'title','inNo','creater','createrDept','operator','operatorDept','operatorDate')
  322. this.$nextTick(() => {
  323. this.form.setFieldsValue(fieldval)
  324. })
  325. // 加载子表数据
  326. if (this.model.id) {
  327. let params = { id: this.model.id }
  328. this.requestSubTableData(this.url.assetInDetail.list, params, this.assetInDetailTable)
  329. }
  330. },
  331. /** 整理成formData */
  332. classifyIntoFormData(allValues) {
  333. let main = Object.assign(this.model, allValues.formValue)
  334. return {
  335. ...main, // 展开
  336. assetInDetailList: allValues.tablesValue[0].values,
  337. }
  338. },
  339. validateError(msg){
  340. this.$message.error(msg)
  341. },
  342. popupCallback(row){
  343. this.form.setFieldsValue(pick(row,'title','inNo','creater','createrDept','operator','operatorDept','operatorDate'))
  344. },
  345. }
  346. }
  347. </script>
  348. <style scoped>
  349. </style>