formParserDialog.vue 10 KB

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