addOrEditDialog.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  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.bankAccount" 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.bankName" 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. export default {
  156. name: 'add-or-edit-dialog',
  157. components: {
  158. processSubmitDialog,
  159. fileMain,
  160. fileUpload,
  161. personSelect,
  162. feeRelatedInfoTable,
  163. customerListDialog,
  164. },
  165. props: {
  166. addOrEditDialogFlag: {
  167. type: Boolean,
  168. default: false
  169. }
  170. },
  171. computed: {
  172. ...mapGetters(['user'])
  173. },
  174. data() {
  175. return {
  176. fullscreen:false,
  177. dialogType: '',
  178. title: '',
  179. form: {
  180. id: '',
  181. documentType: '',
  182. collectionName: '',
  183. collectionId: '',
  184. bankName: '',
  185. bankAccount: '',
  186. accountingSubjectId: '',
  187. accountingSubjectCode: '',
  188. accountingSubjectName: '',
  189. amount: undefined,
  190. applyDeptId: '',
  191. applyDeptName: '',
  192. applyUserId: '',
  193. applyUserName: '',
  194. feeTypeId: '',
  195. feeTypeName: '',
  196. feeTypeCode: '',
  197. files: [],
  198. remark: '',
  199. link: []
  200. },
  201. customerListDialogFlag: false,
  202. processSubmitDialogFlag: false,
  203. feeTypeList: [],
  204. accountingSubjectList: [],
  205. deptList: [],
  206. deptTreeList: [],
  207. rules: {
  208. applyDeptId: { required: true, message: '请选择', trigger: 'change' },
  209. applyUserId: { required: true, message: '请选择', trigger: 'change' },
  210. // accountingSubjectId: {required: true, message: '请选择', trigger: 'change'},
  211. feeTypeId: { required: true, message: '请选择', trigger: 'change' },
  212. amount: { required: true, message: '请输入', trigger: 'blur' },
  213. documentType: { required: true, message: '请选择', trigger: 'change' }
  214. }
  215. };
  216. },
  217. created() {},
  218. methods: {
  219. //初始化
  220. async init(row = {}, type) {
  221. this.title = type == 'add' ? '新增' : '修改';
  222. this.dialogType = type;
  223. await this.getClassifyList(25, 'feeTypeList');
  224. await this.getDeptList();
  225. if (type == 'add') {
  226. this.form.applyDeptId = this.user.info.groupId;
  227. this.form.applyDeptName = this.user.info.groupName;
  228. this.form.applyUserId = this.user.info.userId;
  229. this.form.applyUserName = this.user.info.name;
  230. } else {
  231. await this.getFeeApplyInfoInfo(row.id);
  232. }
  233. this.$nextTick(async () => {
  234. await this.getUserList(this.form.applyDeptId);
  235. });
  236. },
  237. //获取详情
  238. async getFeeApplyInfoInfo(id) {
  239. this.form = await getFeeApplyInfoAPI(id);
  240. this.form.documentType = this.form.documentType + '';
  241. },
  242. //选择供应商
  243. handleSelectContact(row) {
  244. if (this.form.documentType != '3') return;
  245. this.customerListDialogFlag = true;
  246. let params = {
  247. id: '',
  248. assetTreeId: '19',
  249. classType: 2,
  250. titleName: '选择供应商'
  251. };
  252. this.$nextTick(() => {
  253. this.$refs.customerListDialogRef.init(params);
  254. });
  255. },
  256. //获取选择 供应商/客户 数据
  257. async getCustomerData(params) {
  258. let { bankList } = await contactDetail(params.id);
  259. this.form.bankName = bankList[0]?.bankName;
  260. this.form.collectionId = params.id;
  261. this.form.collectionName = params.name;
  262. this.form.bankAccount = bankList[0]?.accountNo;
  263. this.form.amount =''
  264. this.$refs.feeRelatedInfoTable.clearData();
  265. // this.setSelectData(params)
  266. },
  267. //获取分类管理中的数据
  268. async getClassifyList(id, listName) {
  269. let res = await getTreeByPid(id);
  270. this[listName] = res.data;
  271. },
  272. //获取费用类别选中数据
  273. changeFeeTypeInfo(val) {
  274. if (!val) {
  275. this.form.feeTypeName = '';
  276. this.form.feeTypeCode = '';
  277. }
  278. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {};
  279. this.form.feeTypeName = data.name;
  280. this.form.feeTypeCode = data.code;
  281. },
  282. //获取会计科目选中数据
  283. changeSubjectInfo(val) {
  284. if (!val) return (this.form.accountingSubjectName = '');
  285. let data = this.$refs.treeSelect?.$refs?.tree?.getCurrentNode() || {};
  286. this.form.accountingSubjectName = data.name;
  287. },
  288. // 获取部门数据
  289. getDeptList() {
  290. listOrganizations().then((list) => {
  291. this.deptList = list;
  292. this.deptTreeList = this.$util.toTreeData({
  293. data: list,
  294. idField: 'id',
  295. parentIdField: 'parentId'
  296. });
  297. });
  298. },
  299. // 选择负责人部门
  300. changeDeptInfo(id) {
  301. const info = this.deptList.find((e) => e.id == id) || {};
  302. this.form.applyDeptName = info.name;
  303. this.form.applyUserId = '';
  304. this.form.applyUserName = '';
  305. this.getUserList(id);
  306. },
  307. // 获取人员数据
  308. getUserList(deptId) {
  309. if (deptId) {
  310. this.$refs.directorRef.getList({ deptId });
  311. }
  312. },
  313. //选择人员数据
  314. changeUserInfo(val, info) {
  315. this.form.applyUserName = info.name;
  316. },
  317. handleDocumentType(val, oldVal) {
  318. this.$message.warning('单据类型发生变化,请重新选择业务类型');
  319. this.form=Object.assign({},this.form,{
  320. collectionName:'',
  321. collectionId:'',
  322. amount:'',
  323. bankAccount:'',
  324. bankName:''
  325. })
  326. this.$refs.feeRelatedInfoTable.clearData();
  327. },
  328. setTotalPrice(val) {
  329. this.form.amount = val;
  330. },
  331. //
  332. handleSave(flag) {
  333. this.$refs.form.validate(async (valid) => {
  334. if (!valid) return this.$message.warning('有必填项未填,请检查');
  335. this.form.link =
  336. await this.$refs.feeRelatedInfoTable.getTableValidate();
  337. const API =
  338. this.dialogType == 'add' ? feeApplySaveAPI : feeApplyUpdateAPI;
  339. const id = await API(this.form);
  340. if (flag) {
  341. await this.handleSub(id);
  342. return;
  343. }
  344. this.$message.success('操作成功');
  345. this.done();
  346. this.cancel();
  347. });
  348. },
  349. //提交-开启流程
  350. async handleSub(id) {
  351. let data = await getFeeApplyInfoAPI(id);
  352. this.processSubmitDialogFlag = true;
  353. this.$nextTick(() => {
  354. let params = {
  355. businessId: id,
  356. businessKey: 'fin_fee_apply',
  357. formCreateUserId: data.createUserId
  358. };
  359. this.$refs.processSubmitDialogRef.init(params);
  360. });
  361. // try {
  362. // await finFeeApplySubmit({businessId: id})
  363. // } catch (e) {
  364. // this.$message.error(e.message);
  365. // }
  366. },
  367. reload() {
  368. this.done();
  369. this.cancel();
  370. },
  371. //刷新主列表数据
  372. done() {
  373. this.$emit('reload');
  374. },
  375. //关闭弹窗
  376. cancel() {
  377. this.$emit('update:addOrEditDialogFlag', false);
  378. }
  379. }
  380. };
  381. </script>
  382. <style scoped lang="scss"></style>