CheckLoss.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <div style="padding: 0 10px;">
  3. <!-- 导航栏 -->
  4. <Navbar :title="'盘亏数据处理'" :is-go-back="false" />
  5. <!-- 操作按钮 -->
  6. <a-space>
  7. <a-button type="primary" @click="confirmSave">开始处理</a-button>
  8. </a-space>
  9. <!-- 表格 -->
  10. <CommonTable :columns="columns" :data-source="checkVouchsDatas" :have-page="false">
  11. <template #bodyCell="{ column, index }">
  12. <template v-if="column.dataIndex === 'index'">
  13. {{ index + 1 }}
  14. </template>
  15. </template>
  16. </CommonTable>
  17. <!-- 模态框 -->
  18. <a-modal v-model:open="modal" title="提示" @ok="save" @cancel="cancel">
  19. <p>确认开始处理生成出库单?</p>
  20. </a-modal>
  21. </div>
  22. <Loading v-if="loading" />
  23. </template>
  24. <script>
  25. import Common from '../common/Common.js';
  26. import { UserStorageResource } from 'pc-component-v3';
  27. import { message } from 'ant-design-vue';
  28. import CommonTable from '../common/CommonTable.vue';
  29. export default {
  30. components: {
  31. CommonTable,
  32. },
  33. data() {
  34. return {
  35. loading: false,
  36. checkVouchsDatas: [],
  37. checkVouchId: null,
  38. modal: false,
  39. columns: [
  40. { title: '序号', dataIndex: 'index' },
  41. { title: '入库单号', dataIndex: 'stockInDocumentNo' },
  42. { title: '批号', dataIndex: 'batchNo' },
  43. { title: '存货名称', dataIndex: 'invName' },
  44. { title: '规格型号', dataIndex: 'invType' },
  45. { title: '存货编号', dataIndex: 'invCode' },
  46. { title: '货位名称', dataIndex: 'positionName' },
  47. { title: '货位条码', dataIndex: 'positionBarCode' },
  48. { title: '账面数量', dataIndex: 'accountQuantity' },
  49. { title: '盘点数量', dataIndex: 'checkQuantity' },
  50. ],
  51. };
  52. },
  53. mounted() {
  54. const _self = this;
  55. const uuid = _self.$route.params.uuid;
  56. UserStorageResource.uniqueByKey(uuid + '_modelData').then(
  57. str => {
  58. if (str.data) {
  59. const modelData = JSON.parse(str.data);
  60. _self.checkVouchId = modelData.id;
  61. _self.queryCheckVouchses();
  62. }
  63. },
  64. errorData => {
  65. Common.processException(errorData);
  66. },
  67. );
  68. },
  69. methods: {
  70. // 查询需要盘亏的数据
  71. queryCheckVouchses() {
  72. console.log(this.checkVouchId);
  73. const _self = this;
  74. _self.loading = true;
  75. $.ajax({
  76. type: 'get',
  77. dataType: 'json',
  78. url: Common.getApiURL('checkVouchsResource/getCheckLossDatas?checkVouchId=' + _self.checkVouchId),
  79. contentType: 'application/json',
  80. beforeSend: function (request) {
  81. Common.addTokenToRequest(request);
  82. },
  83. success: function (success) {
  84. if (success.errorCode == 0) {
  85. console.log(success);
  86. if (success.datas && success.datas.length > 0) {
  87. _self.checkVouchsDatas = success.datas;
  88. }
  89. } else {
  90. message.warning(success.errorMessage);
  91. }
  92. _self.loading = false;
  93. },
  94. error: function (XMLHttpRequest, textStatus, errorThrown) {
  95. _self.loading = false;
  96. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  97. },
  98. });
  99. },
  100. // 开始处理
  101. confirmSave() {
  102. this.modal = true;
  103. },
  104. // 取消处理
  105. cancel() {
  106. this.modal = false;
  107. },
  108. // 确认处理
  109. save() {
  110. const _self = this;
  111. this.modal = false;
  112. if (this.checkVouchsDatas.length === 0) {
  113. message.warning('没有可处理的数据');
  114. return;
  115. }
  116. _self.loading = true;
  117. $.ajax({
  118. type: 'get',
  119. dataType: 'json',
  120. url: Common.getApiURL('checkVouchsResource/processCheckLossDatas?checkVouchId=' + _self.checkVouchId),
  121. contentType: 'application/json',
  122. beforeSend: function (request) {
  123. Common.addTokenToRequest(request);
  124. },
  125. success: function (success) {
  126. if (success.errorCode == 0) {
  127. message.success('处理成功!');
  128. } else {
  129. message.warning(success.errorMessage);
  130. }
  131. _self.loading = false;
  132. },
  133. error: function (XMLHttpRequest, textStatus, errorThrown) {
  134. _self.loading = false;
  135. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  136. },
  137. });
  138. },
  139. },
  140. };
  141. </script>
  142. <style scoped>
  143. /* 可以根据需要添加额外的样式 */
  144. </style>