taskForm.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <u-cell-group>
  3. <u-cell :border='false' title="基础信息"></u-cell>
  4. <u--form style="margin: 0 20px;" labelPosition="left" :model="form" :rules="rules" ref="uForm"
  5. labelWidth='140rpx'>
  6. <!-- @tap="showDeptPicker" -->
  7. <u-form-item label="申请部门" prop="applyDeptName" borderBottom>
  8. <u--input style="width: 100%;" disabled v-model="form.applyDeptName"></u--input>
  9. <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
  10. </u-form-item>
  11. <!-- @tap="showUserPicker" -->
  12. <u-form-item label="申请人" prop="applyUserName" borderBottom>
  13. <u--input style="width: 100%;" disabled v-model="form.applyUserName"></u--input>
  14. <!-- <u-icon slot="right" name="arrow-right"></u-icon> -->
  15. </u-form-item>
  16. <u-form-item label="费用类型" prop="feeTypeName" borderBottom>
  17. <u--input style="width: 100%;" disabled v-model="form.feeTypeName"></u--input>
  18. </u-form-item>
  19. <u-form-item label="金额" prop="amount" borderBottom>
  20. <u--input style="width: 100%;" disabled v-model="form.amount"></u--input>
  21. </u-form-item>
  22. <u-form-item label="关联类型" prop="finLinkTypeName" borderBottom>
  23. <u--input style="width: 100%;" disabled v-model="form.finLinkTypeName"></u--input>
  24. </u-form-item>
  25. <u-form-item v-if='form.finLinkType==1' label="客户名称" prop="contactName" borderBottom>
  26. <u--input style="width: 100%;" disabled v-model="form.contactName"></u--input>
  27. </u-form-item>
  28. <u-form-item v-if='form.finLinkType==2' label="供应商名称" prop="contactName" borderBottom>
  29. <u--input style="width: 100%;" disabled v-model="form.contactName"></u--input>
  30. </u-form-item>
  31. <u-form-item v-if='form.finLinkType==3' label="商机名称" prop="opportunityName" borderBottom>
  32. <u--input style="width: 100%;" disabled v-model="form.opportunityName"></u--input>
  33. </u-form-item>
  34. <u-form-item v-if='form.finLinkType==4' label="合同名称" prop="contractName" borderBottom>
  35. <u--input style="width: 100%;" disabled v-model="form.contractName"></u--input>
  36. </u-form-item>
  37. <u-form-item v-if='form.finLinkType==5' label="项目名称" prop="projectName" borderBottom>
  38. <u--input style="width: 100%;" disabled v-model="form.projectName"></u--input>
  39. </u-form-item>
  40. <u-form-item v-if='form.finLinkType==6' label="订单名称" prop="saleOrderCode" borderBottom>
  41. <u--input style="width: 100%;" disabled v-model="form.saleOrderCode"></u--input>
  42. </u-form-item>
  43. <u-form-item v-if="['financeApprove'].includes(taskDefinitionKey)" @tap="showAccountPicker" required
  44. label="会计科目" prop="accountingSubjectName" borderBottom>
  45. <u--input style="width: 100%;" v-model="form.accountingSubjectName"></u--input>
  46. <u-icon slot="right" name="arrow-right"></u-icon>
  47. </u-form-item>
  48. <u-form-item label="备注" prop="remark" borderBottom>
  49. <u--textarea style="width: 100%;" disabled v-model="form.remark"></u--textarea>
  50. </u-form-item>
  51. </u--form>
  52. <!-- <ba-tree-picker ref="treePicker" :multiple='false' @select-change="getDeptInfo" title="选择部门"
  53. :localdata='deptTreeList'></ba-tree-picker> -->
  54. <ba-tree-picker ref="accountTreePicker" :multiple='false' clearable @select-change="getAccountInfo"
  55. title="选择会计科目" :localdata='accountingSubjectList'></ba-tree-picker>
  56. </u-cell-group>
  57. </template>
  58. <script>
  59. import {
  60. toTreeData
  61. } from '@/utils/utils.js'
  62. import baTreePicker from '@/components/ba-tree-picker/ba-tree-picker.vue'
  63. import {
  64. feeApplyUpdateAPI,
  65. getFeeApplyInfoAPI
  66. } from '@/api/wt/index.js'
  67. import {
  68. getTreeByPid
  69. } from "@/api/classifyManage";
  70. import {
  71. listOrganizations
  72. } from "@/api/common.js";
  73. export default {
  74. name: 'taskForm1',
  75. components: {
  76. baTreePicker
  77. },
  78. props: {
  79. businessId: {
  80. default: ''
  81. },
  82. taskDefinitionKey: {
  83. default: ''
  84. },
  85. },
  86. data() {
  87. return {
  88. applyDeptShow: true,
  89. form: {
  90. accountingSubjectId: '',
  91. accountingSubjectName: "",
  92. amount: undefined,
  93. applyDeptId: '',
  94. applyDeptName: "",
  95. applyUserId: '',
  96. applyUserName: "",
  97. contactId: '',
  98. contactName: "",
  99. contractCode: "",
  100. contractId: '',
  101. contractName: "",
  102. finLinkType: '',
  103. finLinkTypeName: '',
  104. feeTypeId: '',
  105. feeTypeName: "",
  106. feeTypeCode: "",
  107. files: [],
  108. opportunityId: '',
  109. opportunityName: "",
  110. projectId: '',
  111. projectName: "",
  112. purchaseOrderCode: "",
  113. purchaseOrderId: '',
  114. remark: "",
  115. saleOrderCode: "",
  116. saleOrderId: ''
  117. },
  118. feeTypeList: [],
  119. accountingSubjectList: [],
  120. deptList: [],
  121. deptTreeList: [],
  122. opportunityList: [],
  123. rules: {
  124. applyDeptId: {
  125. type: 'string',
  126. required: true,
  127. message: '请选择',
  128. trigger: 'change'
  129. },
  130. applyUserId: {
  131. type: 'string',
  132. required: true,
  133. message: '请选择',
  134. trigger: 'change'
  135. },
  136. // accountingSubjectId: {required: true, message: '请选择', trigger: 'change'},
  137. feeTypeId: {
  138. type: 'string',
  139. required: true,
  140. message: '请选择',
  141. trigger: 'change'
  142. },
  143. amount: {
  144. type: 'number',
  145. required: true,
  146. message: '请输入',
  147. trigger: 'blur'
  148. },
  149. accountingSubjectName: {
  150. type: 'string',
  151. required: true,
  152. message: '请选择',
  153. trigger: 'blur'
  154. },
  155. }
  156. }
  157. },
  158. async mounted() {
  159. //await this.getClassifyList(25, 'feeTypeList')
  160. await this.getClassifyList(24, 'accountingSubjectList')
  161. //await this.getDeptList()
  162. await this.getFeeApplyInfoInfo(this.businessId)
  163. // await this.getUserList(this.form.applyDeptId);
  164. },
  165. methods: {
  166. //获取详情
  167. async getFeeApplyInfoInfo(id) {
  168. this.form = await getFeeApplyInfoAPI(id)
  169. },
  170. //修改关联类型
  171. handleChangeFinLink(val) {
  172. this.form = Object.assign(this.form, {
  173. accountingSubjectId: '',
  174. accountingSubjectName: "",
  175. contactId: '',
  176. contactName: "",
  177. contractCode: "",
  178. contractId: '',
  179. contractName: "",
  180. opportunityId: '',
  181. opportunityName: "",
  182. projectId: '',
  183. projectName: "",
  184. purchaseOrderCode: "",
  185. purchaseOrderId: '',
  186. saleOrderCode: "",
  187. saleOrderId: ''
  188. })
  189. if (!val.dictValue) return
  190. this.form.finLinkTypeName = val.dictValue || ''
  191. if (val.dictCode == 3) {
  192. this.getOpportunityList()
  193. }
  194. },
  195. //获取分类管理中的数据
  196. async getClassifyList(id, listName) {
  197. let res = await getTreeByPid(id)
  198. this[listName] = res.data
  199. },
  200. //获取费用类别选中数据
  201. changeFeeTypeInfo(val) {
  202. if (!val) {
  203. this.form.feeTypeName = ''
  204. this.form.feeTypeCode = ''
  205. }
  206. let data = this.$refs.feeTypeTree?.$refs?.tree?.getCurrentNode() || {}
  207. this.form.feeTypeName = data.name
  208. this.form.feeTypeCode = data.code
  209. },
  210. // 显示会计科目选择器
  211. showAccountPicker() {
  212. this.$refs.accountTreePicker._show();
  213. },
  214. // 获取会计科目选中数据
  215. getAccountInfo(data, name) {
  216. this.form.accountingSubjectId = data[0]
  217. this.form.accountingSubjectName = name;
  218. },
  219. //获取客户的商机列表
  220. async getOpportunityList() {
  221. const data = await getTableList({
  222. pageNum: 1,
  223. size: 999,
  224. approvalStatus: 2
  225. });
  226. // contactName: name,
  227. this.opportunityList = data.list;
  228. },
  229. //获取选择的商机数据
  230. handleSelectOpportunity(val) {
  231. if (!val) return this.form.opportunityName = ''
  232. this.form.opportunityName = this.opportunityList.find(item => item.id == val)?.name
  233. },
  234. // 显示部门选择器
  235. showDeptPicker() {
  236. this.$refs.treePicker._show();
  237. },
  238. // 获取部门数据
  239. async getDeptList() {
  240. this.deptList = await listOrganizations()
  241. this.deptTreeList = toTreeData({
  242. data: this.deptList,
  243. idField: 'id',
  244. parentIdField: 'parentId'
  245. });
  246. console.log(this.deptTreeList)
  247. },
  248. // 选择负责人部门
  249. getDeptInfo(data, name) {
  250. this.form.applyDeptId = data[0]
  251. this.form.applyDeptName = name;
  252. this.form.applyUserId = '';
  253. this.form.applyUserName = '';
  254. this.getUserList(data[0]);
  255. },
  256. // 获取人员数据
  257. getUserList(deptId) {
  258. // if (deptId) {
  259. // this.$refs.directorRef.getList({
  260. // deptId
  261. // });
  262. // }
  263. },
  264. //选择人员数据
  265. changeUserInfo(val, info) {
  266. this.form.applyUserName = info.name;
  267. },
  268. //
  269. getTableValue() {
  270. return new Promise(async (resolve) => {
  271. try{
  272. const valid = await this.$refs.uForm.validate()
  273. if (valid === true) {
  274. const API = feeApplyUpdateAPI
  275. const id = await API(this.form)
  276. resolve(id)
  277. }
  278. }catch{
  279. resolve(null)
  280. }
  281. })
  282. },
  283. }
  284. }
  285. </script>
  286. <style>
  287. </style>