addOrEditDialog.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div>
  3. <el-form ref="form" :rules="rules" :model="form" label-width="100px">
  4. <headerTitle title="基本信息"></headerTitle>
  5. <el-row :gutter="12">
  6. <el-col :span="8">
  7. <el-form-item
  8. label="单据类型"
  9. prop="documentType"
  10. style="margin-bottom: 22px"
  11. >
  12. <dict-selection
  13. dict-name="单据类型"
  14. v-model="form.documentType"
  15. @change="handleDocumentType"
  16. ></dict-selection>
  17. </el-form-item>
  18. </el-col>
  19. <el-col :span="8">
  20. <el-form-item
  21. label="申请部门"
  22. prop="applyDeptId"
  23. style="margin-bottom: 22px"
  24. >
  25. <ele-tree-select
  26. clearable
  27. :data="deptTreeList"
  28. v-model="form.applyDeptId"
  29. valueKey="id"
  30. labelKey="name"
  31. placeholder="请选择"
  32. @change="changeDeptInfo"
  33. default-expand-all
  34. />
  35. </el-form-item>
  36. </el-col>
  37. <el-col :span="8">
  38. <el-form-item
  39. label="申请人"
  40. prop="applyUserId"
  41. style="margin-bottom: 22px"
  42. >
  43. <personSelect
  44. ref="directorRef"
  45. v-model="form.applyUserId"
  46. @selfChange="changeUserInfo"
  47. />
  48. </el-form-item>
  49. </el-col>
  50. </el-row>
  51. <el-row :gutter="12">
  52. <el-col :span="8">
  53. <el-form-item label="收款名称" style="margin-bottom: 22px">
  54. <el-input
  55. v-model="form.collectionName"
  56. clearable
  57. @click.native="handleSelectContact"
  58. ></el-input>
  59. </el-form-item>
  60. </el-col>
  61. <el-col :span="8">
  62. <el-form-item label="开户行" style="margin-bottom: 22px">
  63. <el-input v-model="form.bankAccount" clearable></el-input>
  64. </el-form-item>
  65. </el-col>
  66. <el-col :span="8">
  67. <el-form-item label="账户" style="margin-bottom: 22px">
  68. <el-input v-model="form.bankName" clearable></el-input>
  69. </el-form-item>
  70. </el-col>
  71. </el-row>
  72. <el-row :gutter="12">
  73. <el-col :span="8">
  74. <el-row style="display: flex; flex-direction: column">
  75. <el-col :span="24">
  76. <el-form-item label="金额" style="margin-bottom: 22px">
  77. <el-input v-model="form.amount" disabled></el-input>
  78. </el-form-item>
  79. </el-col>
  80. <el-col :span="24">
  81. <el-form-item prop="repliedFiles" label="附件">
  82. <fileMain v-model="form.files"></fileMain>
  83. </el-form-item>
  84. </el-col>
  85. </el-row>
  86. </el-col>
  87. <el-col :span="16">
  88. <el-form-item label="备注" style="margin-bottom: 22px">
  89. <el-input
  90. :rows="4"
  91. v-model="form.remark"
  92. type="textarea"
  93. clearable
  94. ></el-input>
  95. </el-form-item>
  96. </el-col>
  97. </el-row>
  98. </el-form>
  99. <headerTitle title="关联信息"></headerTitle>
  100. <fee-related-info-table
  101. ref="feeRelatedInfoTable"
  102. @setTotalPrice="setTotalPrice"
  103. :documentType="form.documentType"
  104. v-if="form.link.length || dialogType == 'add'"
  105. :link.sync="form.link"
  106. ></fee-related-info-table>
  107. <!--选择客户/供应商-->
  108. <customer-list-dialog
  109. v-if="customerListDialogFlag"
  110. :customerListDialogFlag.sync="customerListDialogFlag"
  111. ref="customerListDialogRef"
  112. @changeParent="getCustomerData"
  113. ></customer-list-dialog>
  114. </div>
  115. </template>
  116. <script>
  117. import personSelect from '@/components/CommomSelect/person-select.vue';
  118. import { listOrganizations } from '@/api/system/organization';
  119. import { mapGetters } from 'vuex';
  120. import fileUpload from '@/components/upload/fileUpload.vue';
  121. import {
  122. feeApplyUpdateAPI,
  123. getFeeApplyInfoAPI
  124. } from '@/api/bpm/components/financialManage/fee-manage/fee-application';
  125. import { getTreeByPid } from '@/api/classifyManage';
  126. import { getTableList } from '@/api/bpm/components/saleManage/quotation';
  127. import { getFile } from '@/api/system/file';
  128. import feeRelatedInfoTable from '@/views/bpm/handleTask/components/financialManage/components/feeRelatedInfoTable.vue';
  129. import customerListDialog from '@/views/bpm/handleTask/components/financialManage/components/customerListDialog.vue';
  130. import { contactDetail } from '@/api/bpm/components/saleManage/contact';
  131. // import fileMain from '@/components/addDoc/index.vue';
  132. export default {
  133. name: 'add-or-edit-dialog',
  134. components: {
  135. // fileMain,
  136. fileUpload,
  137. personSelect,
  138. feeRelatedInfoTable,
  139. customerListDialog
  140. },
  141. computed: {
  142. ...mapGetters(['user'])
  143. },
  144. props: {
  145. businessId: {
  146. default: ''
  147. },
  148. taskDefinitionKey: {
  149. default: ''
  150. }
  151. },
  152. data() {
  153. return {
  154. contractListDialogFlag: false,
  155. customerListDialogFlag: false,
  156. dialogType: '',
  157. title: '',
  158. form: {
  159. id: '',
  160. documentType: '',
  161. collectionName: '',
  162. collectionId: '',
  163. bankName: '',
  164. bankAccount: '',
  165. accountingSubjectId: '',
  166. accountingSubjectCode: '',
  167. accountingSubjectName: '',
  168. amount: undefined,
  169. applyDeptId: '',
  170. applyDeptName: '',
  171. applyUserId: '',
  172. applyUserName: '',
  173. feeTypeId: '',
  174. feeTypeName: '',
  175. feeTypeCode: '',
  176. files: [],
  177. remark: '',
  178. link: []
  179. },
  180. feeTypeList: [],
  181. accountingSubjectList: [],
  182. deptList: [],
  183. deptTreeList: [],
  184. rules: {
  185. applyDeptId: { required: true, message: '请选择', trigger: 'change' },
  186. applyUserId: { required: true, message: '请选择', trigger: 'change' },
  187. // accountingSubjectId: {required: true, message: '请选择', trigger: 'change'},
  188. feeTypeId: { required: true, message: '请选择', trigger: 'change' },
  189. amount: { required: true, message: '请输入', trigger: 'blur' },
  190. documentType: { required: true, message: '请选择', trigger: 'change' }
  191. }
  192. };
  193. },
  194. created() {
  195. this.init();
  196. },
  197. methods: {
  198. //初始化
  199. async init(row = {}, type) {
  200. await this.getClassifyList(25, 'feeTypeList');
  201. await this.getClassifyList(24, 'accountingSubjectList');
  202. await this.getDeptList();
  203. await this.getFeeApplyInfoInfo(this.businessId);
  204. this.$nextTick(async () => {
  205. await this.getUserList(this.form.applyDeptId);
  206. });
  207. },
  208. //获取详情
  209. async getFeeApplyInfoInfo(id) {
  210. this.form = await getFeeApplyInfoAPI(id);
  211. this.form.documentType = this.form.documentType + '';
  212. },
  213. //选择供应商
  214. handleSelectContact(row) {
  215. if (this.form.documentType != '3') return;
  216. this.customerListDialogFlag = true;
  217. let params = {
  218. id: '',
  219. assetTreeId: '19',
  220. classType: 2,
  221. titleName: '选择供应商'
  222. };
  223. this.$nextTick(() => {
  224. this.$refs.customerListDialogRef.init(params);
  225. });
  226. },
  227. //获取选择 供应商/客户 数据
  228. async getCustomerData(params) {
  229. let { bankList } = await contactDetail(params.id);
  230. this.form.bankName = bankList[0].bankName;
  231. this.form.collectionId = params.id;
  232. this.form.collectionName = params.name;
  233. this.form.bankAccount = bankList[0].accountNo;
  234. // this.setSelectData(params)
  235. },
  236. downloadFile(file) {
  237. getFile({ objectName: file.storePath }, file.name);
  238. },
  239. //获取分类管理中的数据
  240. async getClassifyList(id, listName) {
  241. let res = await getTreeByPid(id);
  242. this[listName] = res.data;
  243. },
  244. //获取费用类别选中数据
  245. changeFeeTypeInfo(val) {
  246. if (!val) {
  247. this.form.feeTypeName = '';
  248. this.form.feeTypeCode = '';
  249. }
  250. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {};
  251. this.form.feeTypeName = data.name;
  252. this.form.feeTypeCode = data.code;
  253. },
  254. //获取会计科目选中数据
  255. changeSubjectInfo(val) {
  256. if (!val) return (this.form.accountingSubjectName = '');
  257. let data = this.$refs.treeSelect?.$refs?.tree?.getCurrentNode() || {};
  258. this.form.accountingSubjectName = data.name;
  259. },
  260. // 获取部门数据
  261. getDeptList() {
  262. listOrganizations().then((list) => {
  263. this.deptList = list;
  264. this.deptTreeList = this.$util.toTreeData({
  265. data: list,
  266. idField: 'id',
  267. parentIdField: 'parentId'
  268. });
  269. });
  270. },
  271. // 选择负责人部门
  272. changeDeptInfo(id) {
  273. const info = this.deptList.find((e) => e.id == id) || {};
  274. this.form.applyDeptName = info.name;
  275. this.form.applyUserId = '';
  276. this.form.applyUserName = '';
  277. this.getUserList(id);
  278. },
  279. // 获取人员数据
  280. getUserList(deptId) {
  281. if (deptId) {
  282. this.$refs.directorRef.getList({ deptId });
  283. }
  284. },
  285. //选择人员数据
  286. changeUserInfo(val, info) {
  287. this.form.applyUserName = info.name;
  288. },
  289. handleDocumentType(val, oldVal) {
  290. this.$message.warning('单据类型发生变化,请重新选择业务类型');
  291. this.$refs.feeRelatedInfoTable.clearData();
  292. },
  293. setTotalPrice(val) {
  294. this.form.amount = val;
  295. },
  296. //
  297. getTableValue() {
  298. return new Promise((resolve) => {
  299. this.$refs.form.validate(async (valid) => {
  300. if (!valid) return this.$message.warning('有必填项未填,请检查');
  301. this.form.link =
  302. await this.$refs.feeRelatedInfoTable.getTableValidate();
  303. const API = feeApplyUpdateAPI;
  304. const id = await API(this.form);
  305. resolve(id);
  306. });
  307. });
  308. }
  309. }
  310. };
  311. </script>
  312. <style scoped lang="scss"></style>