formParserDialog.vue 11 KB

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