addOrEditDialog.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addOrEditDialogFlag"
  6. :title="title"
  7. :append-to-body="false"
  8. :close-on-click-modal="false"
  9. width="60%"
  10. @close="cancel"
  11. :maxable="true"
  12. :resizable="true"
  13. >
  14. <el-form
  15. ref="form"
  16. class="el-form-box"
  17. :rules="rules"
  18. :model="form"
  19. label-width="120px"
  20. >
  21. <headerTitle title="基本信息"></headerTitle>
  22. <el-row>
  23. <el-col :span="8">
  24. <el-form-item label="单据类型" prop="documentType">
  25. <dict-selection
  26. dict-name="单据类型"
  27. v-model="form.documentType"
  28. @change="handleDocumentType"
  29. ></dict-selection>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="8">
  33. <el-form-item label="申请部门" prop="applyDeptId">
  34. <ele-tree-select
  35. clearable
  36. :data="deptTreeList"
  37. v-model="form.applyDeptId"
  38. valueKey="id"
  39. labelKey="name"
  40. placeholder="请选择"
  41. @change="changeDeptInfo"
  42. default-expand-all
  43. />
  44. </el-form-item>
  45. </el-col>
  46. <el-col :span="8">
  47. <el-form-item label="申请人" prop="applyUserId">
  48. <personSelect
  49. ref="directorRef"
  50. v-model="form.applyUserId"
  51. @selfChange="changeUserInfo"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. </el-row>
  56. <el-row>
  57. <el-col :span="8">
  58. <el-form-item label="收款名称">
  59. <el-input
  60. v-model="form.collectionName"
  61. clearable
  62. @click.native="handleSelectContact"
  63. ></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item label="开户行">
  68. <el-input v-model="form.bankName" clearable></el-input>
  69. </el-form-item>
  70. </el-col>
  71. <el-col :span="8">
  72. <el-form-item label="账户">
  73. <el-input v-model="form.bankAccount" clearable></el-input>
  74. </el-form-item>
  75. </el-col>
  76. </el-row>
  77. <el-row>
  78. <el-col :span="8">
  79. <el-row style="display: flex; flex-direction: column">
  80. <el-col :span="24">
  81. <el-form-item label="金额">
  82. <el-input v-model="form.amount" disabled></el-input>
  83. </el-form-item>
  84. </el-col>
  85. <el-col :span="24">
  86. <el-form-item prop="repliedFiles" label="附件">
  87. <fileMain v-model="form.repliedFiles"></fileMain>
  88. </el-form-item>
  89. </el-col>
  90. </el-row>
  91. </el-col>
  92. <el-col :span="16">
  93. <el-form-item label="备注">
  94. <el-input
  95. :rows="3"
  96. v-model="form.remark"
  97. type="textarea"
  98. clearable
  99. ></el-input>
  100. </el-form-item>
  101. </el-col>
  102. </el-row>
  103. </el-form>
  104. <headerTitle title="关联信息"></headerTitle>
  105. <fee-related-info-table
  106. ref="feeRelatedInfoTable"
  107. v-if="form.link.length || dialogType == 'add'"
  108. :link.sync="form.link"
  109. :documentType="form.documentType"
  110. @setTotalPrice="setTotalPrice"
  111. ></fee-related-info-table>
  112. <div slot="footer">
  113. <el-button type="primary" @click="handleSave(0)">保存</el-button>
  114. <el-button
  115. type="primary"
  116. v-if="isNeed_process_is_close"
  117. @click="handleSave(1)"
  118. >提交</el-button
  119. >
  120. <el-button @click="cancel">返回</el-button>
  121. </div>
  122. <!--选择客户/供应商-->
  123. <customer-list-dialog
  124. v-if="customerListDialogFlag"
  125. :customerListDialogFlag.sync="customerListDialogFlag"
  126. ref="customerListDialogRef"
  127. @changeParent="getCustomerData"
  128. ></customer-list-dialog>
  129. <process-submit-dialog
  130. api-fun-name="finfeeapplyStatusAPI"
  131. :processSubmitDialogFlag.sync="processSubmitDialogFlag"
  132. v-if="processSubmitDialogFlag"
  133. ref="processSubmitDialogRef"
  134. @reload="reload"
  135. ></process-submit-dialog>
  136. </ele-modal>
  137. </template>
  138. <script>
  139. import personSelect from '@/components/CommomSelect/person-select.vue';
  140. import { listOrganizations } from '@/api/system/organization';
  141. import { mapGetters } from 'vuex';
  142. import fileUpload from '@/components/upload/fileUpload.vue';
  143. import {
  144. feeApplySaveAPI,
  145. feeApplyUpdateAPI,
  146. finFeeApplySubmit,
  147. getFeeApplyInfoAPI
  148. } from '@/api/financialManage/fee-manage/fee-application';
  149. import { getTreeByPid } from '@/api/classifyManage';
  150. import feeRelatedInfoTable from '@/views/financialManage/components/feeRelatedInfoTable.vue';
  151. import customerListDialog from '@/views/financialManage/components/customerListDialog.vue';
  152. import { contactDetail } from '@/api/saleManage/contact';
  153. // import fileMain from '@/components/addDoc/index.vue';
  154. import processSubmitDialog from '@/BIZComponents/processSubmitDialog/processSubmitDialog.vue';
  155. import dictMixins from '@/mixins/dictMixins';
  156. export default {
  157. name: 'add-or-edit-dialog',
  158. mixins: [dictMixins],
  159. components: {
  160. processSubmitDialog,
  161. // fileMain,
  162. fileUpload,
  163. personSelect,
  164. feeRelatedInfoTable,
  165. customerListDialog
  166. },
  167. props: {
  168. addOrEditDialogFlag: {
  169. type: Boolean,
  170. default: false
  171. }
  172. },
  173. computed: {
  174. ...mapGetters(['user']),
  175. getDicts() {
  176. return (dictName, val) => {
  177. return this.getDictValue(dictName, val);
  178. };
  179. }
  180. },
  181. data() {
  182. return {
  183. fullscreen: false,
  184. dialogType: '',
  185. title: '',
  186. form: {
  187. id: '',
  188. documentType: '',
  189. collectionName: '',
  190. collectionId: '',
  191. bankName: '',
  192. bankAccount: '',
  193. accountingSubjectId: '',
  194. accountingSubjectCode: '',
  195. accountingSubjectName: '',
  196. amount: undefined,
  197. applyDeptId: '',
  198. applyDeptName: '',
  199. applyUserId: '',
  200. applyUserName: '',
  201. feeTypeId: '',
  202. feeTypeName: '',
  203. feeTypeCode: '',
  204. files: [],
  205. remark: '',
  206. link: []
  207. },
  208. customerListDialogFlag: false,
  209. processSubmitDialogFlag: false,
  210. feeTypeList: [],
  211. accountingSubjectList: [],
  212. deptList: [],
  213. deptTreeList: [],
  214. rules: {
  215. applyDeptId: { required: true, message: '请选择', trigger: 'change' },
  216. applyUserId: { required: true, message: '请选择', trigger: 'change' },
  217. // accountingSubjectId: {required: true, message: '请选择', trigger: 'change'},
  218. feeTypeId: { required: true, message: '请选择', trigger: 'change' },
  219. amount: { required: true, message: '请输入', trigger: 'blur' },
  220. documentType: { required: true, message: '请选择', trigger: 'change' }
  221. }
  222. };
  223. },
  224. created() {},
  225. methods: {
  226. //初始化
  227. async init(row = {}, type) {
  228. this.title = type == 'add' ? '新增' : '修改';
  229. this.dialogType = type;
  230. await this.getClassifyList(25, 'feeTypeList');
  231. await this.getDeptList();
  232. if (type == 'add') {
  233. this.form.applyDeptId = this.user.info.groupId;
  234. this.form.applyDeptName = this.user.info.groupName;
  235. this.form.applyUserId = this.user.info.userId;
  236. this.form.applyUserName = this.user.info.name;
  237. } else {
  238. await this.getFeeApplyInfoInfo(row.id);
  239. }
  240. this.$nextTick(async () => {
  241. await this.getUserList(this.form.applyDeptId);
  242. });
  243. },
  244. //获取详情
  245. async getFeeApplyInfoInfo(id) {
  246. this.form = await getFeeApplyInfoAPI(id);
  247. this.form.documentType = this.form.documentType + '';
  248. },
  249. //选择供应商
  250. handleSelectContact(row) {
  251. if (this.form.documentType != '3') return;
  252. this.customerListDialogFlag = true;
  253. let params = {
  254. id: '',
  255. assetTreeId: '19',
  256. classType: 2,
  257. titleName: '选择供应商'
  258. };
  259. this.$nextTick(() => {
  260. this.$refs.customerListDialogRef.init(params);
  261. });
  262. },
  263. //获取选择 供应商/客户 数据
  264. async getCustomerData(params) {
  265. let { bankList } = await contactDetail(params.id);
  266. this.form.bankName = bankList[0]?.bankName;
  267. this.form.collectionId = params.id;
  268. this.form.collectionName = params.name;
  269. this.form.bankAccount = bankList[0]?.accountNo;
  270. this.form.amount = '';
  271. this.$refs.feeRelatedInfoTable.clearData();
  272. // this.setSelectData(params)
  273. },
  274. //获取分类管理中的数据
  275. async getClassifyList(id, listName) {
  276. let res = await getTreeByPid(id);
  277. this[listName] = res.data;
  278. },
  279. //获取费用类别选中数据
  280. changeFeeTypeInfo(val) {
  281. if (!val) {
  282. this.form.feeTypeName = '';
  283. this.form.feeTypeCode = '';
  284. }
  285. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {};
  286. this.form.feeTypeName = data.name;
  287. this.form.feeTypeCode = data.code;
  288. },
  289. //获取会计科目选中数据
  290. changeSubjectInfo(val) {
  291. if (!val) return (this.form.accountingSubjectName = '');
  292. let data = this.$refs.treeSelect?.$refs?.tree?.getCurrentNode() || {};
  293. this.form.accountingSubjectName = data.name;
  294. },
  295. // 获取部门数据
  296. getDeptList() {
  297. listOrganizations().then((list) => {
  298. this.deptList = list;
  299. this.deptTreeList = this.$util.toTreeData({
  300. data: list,
  301. idField: 'id',
  302. parentIdField: 'parentId'
  303. });
  304. });
  305. },
  306. // 选择负责人部门
  307. changeDeptInfo(id) {
  308. const info = this.deptList.find((e) => e.id == id) || {};
  309. this.form.applyDeptName = info.name;
  310. this.form.applyUserId = '';
  311. this.form.applyUserName = '';
  312. this.getUserList(id);
  313. },
  314. // 获取人员数据
  315. getUserList(deptId) {
  316. if (deptId) {
  317. this.$refs.directorRef.getList({ deptId });
  318. }
  319. },
  320. //选择人员数据
  321. changeUserInfo(val, info) {
  322. this.form.applyUserName = info.name;
  323. },
  324. handleDocumentType(val, oldVal) {
  325. this.$message.warning('单据类型发生变化,请重新选择业务类型');
  326. this.form = Object.assign({}, this.form, {
  327. collectionName: '',
  328. collectionId: '',
  329. amount: '',
  330. bankAccount: '',
  331. bankName: ''
  332. });
  333. this.$refs.feeRelatedInfoTable.clearData();
  334. },
  335. setTotalPrice(val) {
  336. this.form.amount = val;
  337. },
  338. //
  339. handleSave(flag) {
  340. this.$refs.form.validate(async (valid) => {
  341. if (!valid) return this.$message.warning('有必填项未填,请检查');
  342. this.form.link =
  343. await this.$refs.feeRelatedInfoTable.getTableValidate();
  344. const API =
  345. this.dialogType == 'add' ? feeApplySaveAPI : feeApplyUpdateAPI;
  346. const id = await API(this.form);
  347. if (flag) {
  348. await this.handleSub(id);
  349. return;
  350. }
  351. this.$message.success('操作成功');
  352. this.done();
  353. this.cancel();
  354. });
  355. },
  356. //提交-开启流程
  357. async handleSub(id) {
  358. let data = await getFeeApplyInfoAPI(id);
  359. this.processSubmitDialogFlag = true;
  360. this.$nextTick(() => {
  361. let params = {
  362. businessId: id,
  363. businessKey: 'fin_fee_apply',
  364. formCreateUserId: data.createUserId,
  365. variables: {
  366. businessName: this.getDicts('单据类型', data.documentType + ''),
  367. businessType: this.getDicts('单据类型', data.documentType + '')
  368. }
  369. };
  370. this.$refs.processSubmitDialogRef.init(params);
  371. });
  372. // try {
  373. // await finFeeApplySubmit({businessId: id})
  374. // } catch (e) {
  375. // this.$message.error(e.message);
  376. // }
  377. },
  378. reload() {
  379. this.done();
  380. this.cancel();
  381. },
  382. //刷新主列表数据
  383. done() {
  384. this.$emit('reload');
  385. },
  386. //关闭弹窗
  387. cancel() {
  388. this.$emit('update:addOrEditDialogFlag', false);
  389. }
  390. }
  391. };
  392. </script>
  393. <style scoped lang="scss"></style>