AssetsDisposal.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <Navbar title="资产处置-处置申请单" :is-go-back="true" />
  3. <a-row style="display: flex;justify-content: space-between;align-items: center;">
  4. <a-col :span="10">
  5. <a-steps :current="current" size="small" type="navigation" :style="stepStyle" :items="steps" />
  6. </a-col>
  7. <a-col>
  8. <a-button v-if="current > 0" style="margin-right: 8px" @click="prev">上一步</a-button>
  9. <a-button v-if="current < steps.length - 1" type="primary" @click="next">下一步</a-button>
  10. <a-button v-if="current == steps.length - 1 && !isReadonly" type="primary" @click="saveForm">
  11. 确定
  12. </a-button>
  13. </a-col>
  14. </a-row>
  15. <span v-if="current !== 2 && !isReadonly" style="color: red;">注意:处置方式为 “无偿调拨” 和 “捐赠” 的情况不需要选择中介机构,您可以直接单击 "下一步"
  16. 。</span>
  17. <keep-alive>
  18. <DisposalStep1
  19. v-if="current === 0" :disposal-id="disposalId" :is-readonly="isReadonly"
  20. @get-disposal-way="getDisposalWay" @get-nature-ids="getNatureIds"
  21. />
  22. </keep-alive>
  23. <DisposalStep2 v-if="current === 1" ref="disposal2" :disposal-id="disposalId" :is-readonly="isReadonly" />
  24. <keep-alive>
  25. <DisposalStep3
  26. v-if="current === 2" ref="disposal3" :disposal-id="disposalId" :disposal-way="disposalWay"
  27. :is-readonly="isReadonly"
  28. />
  29. </keep-alive>
  30. </template>
  31. <script setup>
  32. import { onMounted, ref } from 'vue';
  33. import { Uuid } from 'pc-component-v3';
  34. import { message } from 'ant-design-vue';
  35. import Common from '../../common/Common.js';
  36. import DisposalStep1 from './DisposalStep1.vue';
  37. import DisposalStep2 from './DisposalStep2.vue';
  38. import DisposalStep3 from './DisposalStep3.vue';
  39. import { addAgencyApi, saveDisposalTwoApi, saveThreeApi, queryStatusApi } from './api.js';
  40. const current = ref(0);
  41. const natureIds = ref(null);
  42. const disposalId = ref('');
  43. const disposalWay = ref('');
  44. const disposal2 = ref();
  45. const disposal3 = ref();
  46. const isReadonly = ref(false);
  47. const steps = [
  48. {
  49. title: '选择中介机构',
  50. },
  51. {
  52. title: '中介机构出具报告',
  53. },
  54. {
  55. title: '填写表单信息',
  56. },
  57. ];
  58. onMounted(() => {
  59. disposalId.value = getQueryParams().disposalId;
  60. if (disposalId.value) queryStatus();
  61. });
  62. // 获取处置方式
  63. const getDisposalWay = way => {
  64. disposalWay.value = way;
  65. };
  66. // 获取中介机构ids
  67. const getNatureIds = id => {
  68. natureIds.value = id;
  69. };
  70. const next = () => {
  71. if (isReadonly.value) {
  72. current.value++;
  73. return;
  74. }
  75. if (current.value === 0) {
  76. if (disposalWay.value === '无偿调拨' || disposalWay.value === '捐赠') {
  77. current.value++;
  78. return;
  79. }
  80. if (natureIds.value) {
  81. addAgency();
  82. } else {
  83. current.value++;
  84. }
  85. } else if (current.value === 1) {
  86. saveDisposalTwo();
  87. }
  88. };
  89. const prev = () => {
  90. current.value--;
  91. };
  92. // 查询处置的状态
  93. const queryStatus = () => {
  94. queryStatusApi(disposalId.value).then(
  95. success => {
  96. if (success.errorCode === 0) {
  97. if (success.data.value === '待审核') {
  98. isReadonly.value = false;
  99. } else {
  100. isReadonly.value = true;
  101. current.value = 2;
  102. }
  103. } else {
  104. message.warning(success.errorMessage);
  105. }
  106. },
  107. error => {
  108. Common.processException(error);
  109. },
  110. );
  111. };
  112. // 保存表单数据
  113. const saveForm = () => {
  114. const formDatas = { ...disposal3.value.formState };
  115. const { operatorName, operatorNum, documentNumber, applyFileName, responsibilityName, disposalReason } = formDatas;
  116. if (!operatorName) {
  117. message.warning('请您填写经办人。');
  118. return;
  119. }
  120. if (!operatorNum) {
  121. message.warning('请您填写经办人联系方式。');
  122. return;
  123. }
  124. if (!documentNumber) {
  125. message.warning('请您填写文号。');
  126. return;
  127. }
  128. if (!applyFileName) {
  129. message.warning('请您填写单位申请文件名称。');
  130. return;
  131. }
  132. if (!responsibilityName) {
  133. message.warning('请您填写责任人名称。');
  134. return;
  135. }
  136. const params = {
  137. assetDisposalApplyId: disposalId.value,
  138. operatorName,
  139. operatorNum,
  140. documentNumber,
  141. applyFileName,
  142. responsibilityName,
  143. disposalReason,
  144. attachmentMaterialsIds: disposal3.value.fileIds,
  145. };
  146. saveThreeApi(params).then(
  147. success => {
  148. if (success.errorCode === 0) {
  149. message.success('生成资产处置单成功。');
  150. window.open(
  151. '/#/desktop/window1/20241101_113732' + '?uuid=' + Uuid.createUUID(),
  152. '_self',
  153. );
  154. } else {
  155. message.warning(success.errorMessage);
  156. }
  157. },
  158. error => {
  159. Common.processException(error);
  160. },
  161. );
  162. };
  163. // 添加中介
  164. const addAgency = () => {
  165. const params = {
  166. assetDisposalApplyId: disposalId.value,
  167. assetAgencyId: natureIds.value,
  168. };
  169. addAgencyApi(params).then(
  170. success => {
  171. if (success.errorCode !== 0) {
  172. message.warning(success.errorMessage);
  173. } else {
  174. current.value++;
  175. }
  176. },
  177. error => {
  178. Common.processException(error);
  179. },
  180. );
  181. };
  182. // 保存中介机构出具报告
  183. const saveDisposalTwo = () => {
  184. const params = {
  185. ...disposal2.value.getSaveDatas(),
  186. };
  187. saveDisposalTwoApi(params).then(
  188. success => {
  189. if (success.errorCode !== 0) {
  190. message.warning(success.errorMessage);
  191. } else {
  192. current.value++;
  193. }
  194. },
  195. error => {
  196. Common.processException(error);
  197. },
  198. );
  199. };
  200. // 获取单据Id
  201. const getQueryParams = () => {
  202. const url = window.location.href;
  203. let urlStr = url.split('?')[1];
  204. const urlSearchParams = new URLSearchParams(urlStr);
  205. const result = Object.fromEntries(urlSearchParams.entries());
  206. return result;
  207. };
  208. const stepStyle = {
  209. marginBottom: '8px',
  210. boxShadow: '0px -1px 0 0 #e8e8e8 inset',
  211. };
  212. </script>
  213. <style scoped>
  214. :deep(.ant-steps.ant-steps-navigation) {
  215. padding-top: 6px;
  216. }
  217. </style>