AssetBatchOperationQueue.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <CommonTable
  3. ref="table" :columns="columns" :data-source="assetChangeWaitDtos" :total="pagination.total"
  4. :is-select="true" @get-pager="getPageParams" @get-selected="getSelectParams"
  5. >
  6. <template #bodyCell="{ column, record }">
  7. <template v-if="column.dataIndex === 'clientName'">
  8. {{ record.clientName }} {{ record.organizationName }}
  9. </template>
  10. <template v-if="column.dataIndex === 'responseClientName'">
  11. {{ record.responseClientName }} {{ record.responseOrganizationName }}
  12. </template>
  13. </template>
  14. </CommonTable>
  15. <Loading v-if="loading" />
  16. </template>
  17. <script>
  18. import AssetBatchOperationQueueResource from '../../api/asset/AssetBatchOperationQueueResource.js';
  19. import Common from '../../common/Common.js';
  20. import { Uuid } from 'pc-component-v3';
  21. import CommonTable from '../../common/CommonTable.vue';
  22. export default {
  23. components: {
  24. CommonTable,
  25. },
  26. props: {
  27. changeType: {
  28. type: String,
  29. default: null,
  30. },
  31. },
  32. data: function () {
  33. return {
  34. assetChangeWaitDtos: [],
  35. pagination: {
  36. total: 0,
  37. per_page: Common.pageSize, // required
  38. current_page: 1, // required
  39. last_page: 0, // required
  40. },
  41. checked: false,
  42. tableId: Uuid.createUUID(),
  43. loading: false,
  44. columns: [
  45. { title: this.$t('lang.AssetBatchOperationQueue.assetName'), dataIndex: 'name', width: 160 },
  46. { title: this.$t('lang.AssetBatchOperationQueue.assetNumber'), dataIndex: 'assetNo', width: 240 },
  47. { title: this.$t('lang.AssetBatchOperationQueue.cardNumber'), dataIndex: 'no', width: 240 },
  48. { title: this.$t('lang.AssetBatchOperationQueue.ownerDepartment'), dataIndex: 'clientName', width: 150 },
  49. { title: this.$t('lang.AssetBatchOperationQueue.useDepartment'), dataIndex: 'responseClientName', width: 150 },
  50. { title: this.$t('lang.AssetBatchOperationQueue.type'), dataIndex: 'type', width: 150 },
  51. { title: this.$t('lang.AssetBatchOperationQueue.projectName'), dataIndex: 'projectItemName', width: 150 },
  52. { title: this.$t('lang.AssetBatchOperationQueue.assetCategory'), dataIndex: 'categoryName', width: 150 },
  53. { title: this.$t('lang.AssetBatchOperationQueue.originalValue'), dataIndex: 'orginalValue', width: 150 },
  54. { title: this.$t('lang.AssetBatchOperationQueue.placeOfPlacement'), dataIndex: 'savePosition', width: 150 },
  55. { title: this.$t('lang.AssetBatchOperationQueue.aLocationToBePlacedIn'), dataIndex: 'locationName', width: 150 },
  56. { title: this.$t('lang.AssetBatchOperationQueue.startDate'), dataIndex: 'depreciationStartDate', width: 150 },
  57. { title: this.$t('lang.AssetBatchOperationQueue.user'), dataIndex: 'useUserName', width: 150 },
  58. { title: this.$t('lang.AssetBatchOperationQueue.userInput'), dataIndex: 'useUserNameInput', width: 150 },
  59. { title: this.$t('lang.AssetBatchOperationQueue.usageStatus'), dataIndex: 'useStatusName', width: 150 },
  60. ].map(column => ({
  61. ...column,
  62. ellipsis: true,
  63. align: 'center',
  64. resizable: true,
  65. })),
  66. waitChangeAssetDtos: [],
  67. };
  68. },
  69. mounted: function () {
  70. var _self = this;
  71. _self.getDatas();
  72. },
  73. methods: {
  74. /**
  75. * 重置分页,然后查询
  76. */
  77. resetQuery: function () {
  78. var _self = this;
  79. _self.$refs.table.backFirstPage();
  80. },
  81. getPageParams: function (pager, pageSize) {
  82. var _self = this;
  83. _self.pagination.current_page = pager;
  84. _self.pagination.per_page = pageSize;
  85. _self.getDatas();
  86. },
  87. getSelectParams: function (selected) {
  88. this.waitChangeAssetDtos = selected.selectedRows;
  89. console.log(this.waitChangeAssetDtos);
  90. },
  91. /**
  92. * 调拨经手人框change事件
  93. */
  94. userValueChanged: function (newResponsibilityFieldValue) {
  95. this.userFieldValue = newResponsibilityFieldValue;
  96. },
  97. /**
  98. * /查询数据
  99. */
  100. getDatas: function (isClear = false, isClearTable = false) {
  101. var _self = this;
  102. if (isClearTable) {
  103. _self.$refs.table.backFirstPage();
  104. return;
  105. }
  106. _self.loading = true;
  107. var param = {
  108. range: {
  109. start:
  110. (_self.pagination.current_page - 1) * _self.pagination.per_page,
  111. length: _self.pagination.per_page,
  112. },
  113. changeType: _self.changeType,
  114. };
  115. AssetBatchOperationQueueResource.listByCondition(param).then(
  116. baseRangeResponse => {
  117. if (baseRangeResponse.errorCode == 0) {
  118. _self.pagination.total = baseRangeResponse.total;
  119. if (baseRangeResponse.datas && baseRangeResponse.datas.length > 0) {
  120. baseRangeResponse.datas.forEach(function (item) {
  121. item.assetSimpleResponse.assetChangeWaitId = item.id;
  122. });
  123. _self.assetChangeWaitDtos = baseRangeResponse.datas.map(item => item.assetSimpleResponse);
  124. } else {
  125. _self.assetChangeWaitDtos.splice(0, _self.assetChangeWaitDtos.length);
  126. _self.waitChangeAssetDtos.splice(0, _self.waitChangeAssetDtos.length);
  127. }
  128. if (isClear) {
  129. _self.$refs.table.clear();
  130. }
  131. } else {
  132. Common.showDialog('提示', baseRangeResponse.errorMessage, 'error');
  133. }
  134. _self.loading = false;
  135. },
  136. errorData => {
  137. _self.loading = false;
  138. Common.processException(errorData);
  139. },
  140. );
  141. },
  142. /**
  143. * 取消转移
  144. */
  145. removeAssetChangeWaitDtos: function () {
  146. var _self = this;
  147. if (_self.waitChangeAssetDtos.length < 1) {
  148. Common.showDialog('提示', '请选择数据后再提交', 'error');
  149. return;
  150. }
  151. _self.loading = true;
  152. if (_self.waitChangeAssetDtos.length > 0) {
  153. let removeDtos = [];
  154. _self.waitChangeAssetDtos.forEach(function (item) {
  155. let removeDto = {
  156. assetSimpleResponse: item,
  157. id: item.assetChangeWaitId,
  158. };
  159. removeDtos.push(removeDto);
  160. });
  161. AssetBatchOperationQueueResource.remove(removeDtos).then(
  162. baseListResponse => {
  163. if (baseListResponse.errorCode == 0) {
  164. _self.getDatas(true);
  165. Common.showDialog('提示', '取消成功', 'success');
  166. } else {
  167. Common.showDialog('提示', baseListResponse.errorMessage, 'error');
  168. }
  169. _self.loading = false;
  170. },
  171. errorData => {
  172. _self.loading = false;
  173. Common.processException(errorData);
  174. },
  175. );
  176. }
  177. },
  178. /**
  179. * 获取转移资产DTO集合
  180. */
  181. getAssetChangeDtos: function () {
  182. var _self = this;
  183. let assetChangeDtos = [];
  184. _self.waitChangeAssetDtos.forEach(function (item) {
  185. let assetChangeDto = {
  186. assetInstanceId: item.id,
  187. assetChangeWaitId: item.assetChangeWaitId,
  188. };
  189. assetChangeDtos.push(assetChangeDto);
  190. });
  191. return assetChangeDtos;
  192. },
  193. },
  194. };
  195. </script>
  196. <style scoped></style>