formParserDialog.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <ele-modal
  3. :visible="formParserDialogFlag"
  4. title="审批"
  5. :width="modelWidth"
  6. :centered="true"
  7. :close-on-click-modal="false"
  8. append-to-body
  9. :before-close="cancel"
  10. :maxable="true"
  11. :resizable="true"
  12. >
  13. <div class="row">主题: {{ form.businessName }}</div>
  14. <div class="row">提交人: {{ form.processInstance?.startUserNickname }}</div>
  15. <div class="row">提交时间: {{ form.createTime }}</div>
  16. <fm-generate-form
  17. v-if="Object.keys(form?.formJson || {}).length !== 0"
  18. :data="jsonData"
  19. :value="form.valueJson"
  20. ref="generateForm"
  21. >
  22. <template v-slot:blank_adopzrdd="scope">
  23. <div v-for="(item, index) in scope.model.blank_adopzrdd" :key="index">
  24. <div class="blank_adopzrdd">
  25. <span>{{ index + 1 }}报销事项:</span>
  26. <el-input
  27. v-model="scope.model.blank_adopzrdd[index].remark"
  28. type="textarea"
  29. style="width: calc(100% - 80px)"
  30. ></el-input>
  31. </div>
  32. <div class="blank_adopzrdd">
  33. <span>金额:</span>
  34. <el-input
  35. v-model="scope.model.blank_adopzrdd[index].price"
  36. type="number"
  37. style="width: calc(100% - 80px)"
  38. ></el-input>
  39. </div>
  40. </div>
  41. </template>
  42. <!-- 客户名称 -->
  43. <template v-slot:eom_contact="scope">
  44. <div class="eom_contact">
  45. <el-input
  46. v-model="scope.model.eom_contact.name"
  47. style="width: 100%"
  48. :disabled="view"
  49. ></el-input>
  50. </div>
  51. </template>
  52. <!-- 关联工单 -->
  53. <template v-slot:manage_workorder="scope">
  54. <div class="manage_workorder">
  55. <el-input
  56. v-model="scope.model.manage_workorder.code"
  57. style="width: 100%"
  58. :disabled="view"
  59. ></el-input>
  60. </div>
  61. </template>
  62. <!-- 差旅 -->
  63. <template v-slot:blank_business_component="scope">
  64. <businessComponent
  65. ref="blank_business_component"
  66. id="blank_business_component"
  67. :generateForm="$refs.generateForm"
  68. :info="scope.model"
  69. :view="view"
  70. ></businessComponent>
  71. </template>
  72. <!-- 印章使用 -->
  73. <template v-slot:blank_use_seal="scope">
  74. <useSealComponent
  75. ref="blank_use_seal"
  76. id="blank_use_seal"
  77. :generateForm="$refs.generateForm"
  78. :info="scope.model"
  79. :view="view"
  80. ></useSealComponent>
  81. </template>
  82. <!-- 资质使用 -->
  83. <template v-slot:blank_use_qualification="scope">
  84. <useQualificationComponent
  85. ref="blank_use_qualification"
  86. id="blank_use_qualification"
  87. :generateForm="$refs.generateForm"
  88. :info="scope.model"
  89. :view="view"
  90. ></useQualificationComponent>
  91. </template>
  92. <!-- 产品规格 -->
  93. <template v-slot:blank_product_specification="scope">
  94. <productSpecificationComponent
  95. ref="blank_product_specification"
  96. id="blank_product_specification"
  97. :generateForm="$refs.generateForm"
  98. :info="scope.model"
  99. :view="view"
  100. ></productSpecificationComponent>
  101. </template>
  102. <!-- 事件 -->
  103. <template v-slot:blank_event_component="scope">
  104. <eventComponent
  105. ref="blank_event_component"
  106. id="blank_event_component"
  107. :generateForm="$refs.generateForm"
  108. :info="scope.model"
  109. :view="view"
  110. ></eventComponent>
  111. </template>
  112. <!-- 补发 -->
  113. <template v-slot:blank_reissue_component="scope">
  114. <reissueComponent
  115. ref="blank_reissue_component"
  116. id="blank_reissue_component"
  117. :generateForm="$refs.generateForm"
  118. :info="scope.model"
  119. :view="view"
  120. ></reissueComponent>
  121. </template>
  122. </fm-generate-form>
  123. <outboundXTBG
  124. v-if="form.taskDefinitionKey == 'CGYSP'"
  125. :biz-type="4"
  126. :source-biz-no="form?.processInstance.id"
  127. ref="outboundXTBGRef"
  128. ></outboundXTBG>
  129. <div slot="footer" class="dialog-footer">
  130. <el-form label-width="100px" ref="formRef" :model="form">
  131. <!-- prop="reason" -->
  132. <el-form-item
  133. label="审批建议"
  134. style="margin-bottom: 20px"
  135. :rules="{
  136. required: true,
  137. message: '',
  138. trigger: 'blur'
  139. }"
  140. >
  141. <el-input
  142. type="textarea"
  143. v-model="form.reason"
  144. placeholder="请输入审批建议"
  145. />
  146. </el-form-item>
  147. </el-form>
  148. <el-button
  149. icon="el-icon-edit-outline"
  150. type="success"
  151. size="mini"
  152. @click="handleAudit(1)"
  153. v-if="form.taskDefinitionKey != 'CGYSP'"
  154. >通过
  155. </el-button>
  156. <el-button
  157. icon="el-icon-edit-outline"
  158. type="success"
  159. size="mini"
  160. :loading="isSaveLoading"
  161. @click="storemanApprove(1)"
  162. v-if="form.taskDefinitionKey == 'CGYSP'"
  163. >出库
  164. </el-button>
  165. <el-button
  166. icon="el-icon-circle-close"
  167. type="danger"
  168. size="mini"
  169. @click="handleAudit(0)"
  170. >驳回
  171. </el-button>
  172. <el-dropdown
  173. @command="(command) => handleCommand(command)"
  174. style="margin-left: 30px"
  175. >
  176. <span class="el-dropdown-link">
  177. 更多<i class="el-icon-arrow-down el-icon--right"></i>
  178. </span>
  179. <el-dropdown-menu slot="dropdown">
  180. <el-dropdown-item command="cancel">作废</el-dropdown-item>
  181. </el-dropdown-menu>
  182. </el-dropdown>
  183. </div>
  184. </ele-modal>
  185. </template>
  186. <script>
  187. import Parser from '@/components/FormGenerator/components/parser/Parser.vue';
  188. import outboundXTBG from '@/views/bpm/outgoingManagement/outboundXTBG.vue';
  189. import {
  190. approveTaskWithVariables,
  191. cancelTask,
  192. rejectTask
  193. } from '@/api/bpm/task';
  194. import { getToken } from '@/utils/token-util';
  195. import storageApi from '@/api/warehouseManagement';
  196. import businessComponent from '@/BIZComponents/processSubmitDialog/components/businessComponent.vue';
  197. import useSealComponent from '@/BIZComponents/processSubmitDialog/components/useSealComponent.vue';
  198. import useQualificationComponent from '@/BIZComponents/processSubmitDialog/components/useQualificationComponent.vue';
  199. import productSpecificationComponent from '@/BIZComponents/processSubmitDialog/components/productSpecificationComponent.vue';
  200. import eventComponent from '@/BIZComponents/processSubmitDialog/components/eventComponent.vue';
  201. import reissueComponent from '@/BIZComponents/processSubmitDialog/components/reissueComponent.vue';
  202. import { processInstanceValueJsonChange } from '@/api/bpm/processInstance';
  203. export default {
  204. name: 'formParserDialog',
  205. components: {
  206. Parser,
  207. outboundXTBG,
  208. businessComponent,
  209. useSealComponent,
  210. useQualificationComponent,
  211. productSpecificationComponent,
  212. eventComponent,
  213. reissueComponent
  214. },
  215. props: {
  216. businessId: {
  217. default: ''
  218. },
  219. formParserDialogFlag: {
  220. type: Boolean,
  221. default: false
  222. }
  223. },
  224. data() {
  225. return {
  226. form: {},
  227. index: '',
  228. jsonData: {},
  229. width: '30%',
  230. isSaveLoading: false,
  231. view: true
  232. };
  233. },
  234. computed: {
  235. modelWidth() {
  236. let width =
  237. this.jsonData.config?.platform && this.jsonData.config.platform === 'pc'
  238. ? 1100
  239. : 450;
  240. if (this.form?.taskDefinitionKey == 'CGYSP') {
  241. return (width = '70%');
  242. }
  243. return width + 'px';
  244. }
  245. },
  246. methods: {
  247. open(row) {
  248. this.form = _.cloneDeep(row);
  249. console.log(this.form.taskDefinitionKey, 'this.form.taskDefinitionKey');
  250. this.jsonData = JSON.parse(this.form.formJson.makingJson);
  251. this.jsonData.config.dataSource &&
  252. this.jsonData.config.dataSource.forEach((item) => {
  253. item.headers = {
  254. Authorization: getToken()
  255. };
  256. // item.url = item.url && item.url.replace('/api', this.APIUrl);
  257. });
  258. this.$nextTick(async() => {
  259. let data = await this.$refs.generateForm.getData(false);
  260. console.log('data~~~~~', data);
  261. // this.$refs.generateForm.disabled(['input_bonus_distribution_ratio', 'input_manager_approval_fee'], true)
  262. let arr = Object.keys(data)?.filter((item) => item != 'input_bonus_distribution_ratio' && item != 'input_manager_approval_fee')
  263. console.log(arr, 'arr');
  264. this.$refs.generateForm.disabled(arr, true)
  265. })
  266. },
  267. cancel() {
  268. this.$emit('update:formParserDialogFlag', false);
  269. },
  270. async handleAudit(status) {
  271. const data = await this.$refs.generateForm.getData(false);
  272. await processInstanceValueJsonChange(this.form.processInstance.id, data)
  273. console.log('form', this.form);
  274. console.log('processInstanceValueJsonChange', await this.$refs.generateForm.getData(false));
  275. // return
  276. await this._approveTaskWithVariables(status);
  277. },
  278. async storemanApprove(status) {
  279. let storageData = await this.$refs.outboundXTBGRef.getReturnStorage();
  280. console.log(storageData);
  281. // 出库来源isSkip 0-正常 1-外部(外部跳过内部审核流程)
  282. storageData.isSkip = 1;
  283. storageData.isMes = 1;
  284. try {
  285. this.isSaveLoading = true;
  286. await storageApi.outStorage(storageData);
  287. approveTaskWithVariables({
  288. id: this.form.id,
  289. reason: this.form.reason,
  290. businessId: this.businessId,
  291. variables: {
  292. pass: true
  293. }
  294. }).then((res) => {
  295. if (res.data.code != '-1') {
  296. this.$message.success(`出库成功!`);
  297. this.$emit('reload');
  298. this.cancel();
  299. }
  300. this.isSaveLoading = false;
  301. });
  302. } catch (error) {
  303. this.isSaveLoading = false;
  304. console.error('出库失败:', error);
  305. }
  306. },
  307. async _approveTaskWithVariables(status) {
  308. let variables = {
  309. pass: !!status
  310. };
  311. let API = !!status ? approveTaskWithVariables : rejectTask;
  312. API({
  313. id: this.form.id,
  314. reason: this.form.reason,
  315. businessId: this.businessId,
  316. variables
  317. }).then((res) => {
  318. if (res.data.code != '-1') {
  319. let params = {
  320. status,
  321. title: status === 0 ? '驳回' : ''
  322. };
  323. this.$message.success(`审批${params.title}成功!`);
  324. this.$emit('reload');
  325. this.cancel();
  326. }
  327. });
  328. },
  329. //更多
  330. handleCommand(command) {
  331. if (command === 'cancel') {
  332. this.$confirm('是否确认作废?', {
  333. type: 'warning',
  334. cancelButtonText: '取消',
  335. confirmButtonText: '确定'
  336. })
  337. .then(() => {
  338. cancelTask({
  339. taskId: this.form.id,
  340. id: this.form.processInstance.id,
  341. reason: this.form.reason
  342. })
  343. .then(() => {
  344. this.$emit('reload');
  345. this.cancel();
  346. })
  347. .catch(() => {
  348. this.$message.error('流程作废失败');
  349. });
  350. })
  351. .catch(() => {});
  352. }
  353. }
  354. }
  355. };
  356. </script>
  357. <style scoped lang="scss">
  358. .blank_adopzrdd {
  359. display: flex;
  360. align-items: center;
  361. > span {
  362. display: inline-block;
  363. width: 80px;
  364. }
  365. margin-bottom: 10px;
  366. }
  367. .row {
  368. margin-bottom: 10px;
  369. }
  370. </style>