addOrEditDialog.vue 14 KB

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