AssetBatchOperationQueue.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <div style="height: 100%;">
  3. <div class="grid-container">
  4. <div class="grid-item-1">
  5. <table :id="tableId" class="fixed-table table table-striped table-bordered">
  6. <thead>
  7. <tr>
  8. <th style="width: 40px">
  9. <input
  10. v-model="checked"
  11. autocomplete="off"
  12. type="checkbox"
  13. :checked="checked"
  14. @change="selectAll()"
  15. />
  16. </th>
  17. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.assetName') }}</th>
  18. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.assetNumber') }}</th>
  19. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.cardNumber') }}</th>
  20. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.ownerDepartment') }}</th>
  21. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.useDepartment') }}</th>
  22. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.type') }}</th>
  23. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.projectName') }}</th>
  24. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.assetCategory') }}</th>
  25. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.originalValue') }}</th>
  26. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.placeOfPlacement') }}</th>
  27. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.aLocationToBePlacedIn') }}</th>
  28. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.startDate') }}</th>
  29. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.user') }}</th>
  30. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.userInput') }}</th>
  31. <th style="width: 150px">{{ $t('lang.AssetBatchOperationQueue.usageStatus') }}</th>
  32. </tr>
  33. </thead>
  34. <tbody v-if="assetChangeWaitDtos.length > 0">
  35. <tr
  36. v-for="item in assetChangeWaitDtos"
  37. :key="item.id"
  38. >
  39. <td>
  40. <input
  41. autocomplete="off"
  42. type="checkbox"
  43. name="checkboxinput"
  44. :checked="item.checked"
  45. @click="item.checked = !item.checked"
  46. />
  47. </td>
  48. <td>{{ item.assetSimpleResponse.name }}</td>
  49. <td>{{ item.assetSimpleResponse.assetNo }}</td>
  50. <td>{{ item.assetSimpleResponse.no }}</td>
  51. <td>{{ item.assetSimpleResponse.clientName }}&nbsp;{{ item.assetSimpleResponse.organizationName }}</td>
  52. <td>{{ item.assetSimpleResponse.responseClientName }}&nbsp;{{ item.assetSimpleResponse.responseOrganizationName }}</td>
  53. <td>{{ item.assetSimpleResponse.type }}</td>
  54. <td>{{ item.assetSimpleResponse.projectItemName }}</td>
  55. <td>{{ item.assetSimpleResponse.categoryName }}</td>
  56. <td>{{ item.assetSimpleResponse.orginalValue }}</td>
  57. <td>{{ item.assetSimpleResponse.savePosition }}</td>
  58. <td>{{ item.assetSimpleResponse.locationName }}</td>
  59. <td>{{ item.assetSimpleResponse.depreciationStartDate }}</td>
  60. <td>{{ item.assetSimpleResponse.useUserName }}</td>
  61. <td>{{ item.assetSimpleResponse.useUserNameInput }}</td>
  62. <td>{{ item.assetSimpleResponse.useStatusName }}</td>
  63. </tr>
  64. </tbody>
  65. </table>
  66. </div>
  67. <div class="grid-item-2">
  68. <VueBootstrapPagination
  69. v-if="pagination.last_page > 0"
  70. :pagination="pagination"
  71. :callback="getDatas"
  72. :show-head-and-tail="true"
  73. />
  74. </div>
  75. </div>
  76. <Loading v-if="loading" />
  77. </div>
  78. </template>
  79. <script>
  80. import AssetBatchOperationQueueResource from '../../api/asset/AssetBatchOperationQueueResource.js';
  81. import Common from '../../common/Common.js';
  82. import { Uuid } from 'pc-component-v3';
  83. export default {
  84. components: {
  85. },
  86. props: {
  87. changeType: {
  88. type: String,
  89. default: null,
  90. },
  91. },
  92. data: function () {
  93. return {
  94. assetChangeWaitDtos: [],
  95. pagination: {
  96. total: 0,
  97. per_page: Common.pageSize, // required
  98. current_page: 1, // required
  99. last_page: 0, // required
  100. },
  101. checked: false,
  102. tableId: Uuid.createUUID(),
  103. loading: false,
  104. };
  105. },
  106. mounted: function () {
  107. var _self = this;
  108. _self.getDatas();
  109. this.fixedTableHeader();
  110. this.$nextTick(function () {
  111. // 可调整表格列宽
  112. $('#' + _self.tableId).resizableColumns();
  113. });
  114. },
  115. methods: {
  116. /**
  117. * 重置分页,然后查询
  118. */
  119. resetQuery: function () {
  120. var _self = this;
  121. _self.pagination.current_page = 1;
  122. _self.getDatas();
  123. },
  124. /**
  125. * 调拨经手人框change事件
  126. */
  127. userValueChanged: function (newResponsibilityFieldValue) {
  128. var _self = this;
  129. this.userFieldValue = newResponsibilityFieldValue;
  130. },
  131. /**
  132. * 全选和反选
  133. */
  134. selectAll: function () {
  135. var _self = this;
  136. if (_self.checked) {
  137. for (var i = 0; i < _self.assetChangeWaitDtos.length; i++) {
  138. _self.assetChangeWaitDtos[i].checked = true;
  139. }
  140. } else {
  141. for (var j = 0; j < _self.assetChangeWaitDtos.length; j++) {
  142. _self.assetChangeWaitDtos[j].checked = false;
  143. }
  144. }
  145. },
  146. /**
  147. * /查询数据
  148. */
  149. getDatas: function () {
  150. var _self = this;
  151. _self.loading=true;
  152. var param = {
  153. range: {
  154. start:
  155. (_self.pagination.current_page - 1) * _self.pagination.per_page,
  156. length: _self.pagination.per_page,
  157. },
  158. changeType: _self.changeType,
  159. };
  160. AssetBatchOperationQueueResource.listByCondition(param).then(
  161. baseRangeResponse => {
  162. if(baseRangeResponse.errorCode == 0){
  163. _self.pagination.total = baseRangeResponse.total;
  164. if (baseRangeResponse.datas) {
  165. baseRangeResponse.datas.forEach(function (item) {
  166. item.checked = false;
  167. });
  168. }
  169. _self.assetChangeWaitDtos = baseRangeResponse.datas;
  170. _self.loading=false;
  171. if (baseRangeResponse.datas == undefined ||
  172. baseRangeResponse.datas.length == 0) {
  173. return;
  174. }
  175. _self.pagination.last_page = Math.ceil(
  176. baseRangeResponse.total / baseRangeResponse.length,
  177. );
  178. }else{
  179. Common.showDialog('提示', baseRangeResponse.errorMessage, 'error');
  180. }
  181. _self.fixedTableHeader();
  182. },
  183. errorData => {
  184. _self.loading=false;
  185. Common.processException(errorData);
  186. },
  187. );
  188. },
  189. /**
  190. * 取消转移
  191. */
  192. removeAssetChangeWaitDtos: function () {
  193. var _self = this;
  194. let waitChangeAssetDtos = [];
  195. this.assetChangeWaitDtos.forEach(function (item) {
  196. if (item.checked) {
  197. waitChangeAssetDtos.push(item);
  198. }
  199. });
  200. if (waitChangeAssetDtos.length < 1) {
  201. Common.showDialog('提示', '请选择数据后再提交', 'error');
  202. return;
  203. }
  204. _self.loading=true;
  205. if (waitChangeAssetDtos.length > 0) {
  206. AssetBatchOperationQueueResource.remove(
  207. waitChangeAssetDtos,
  208. ).then(
  209. baseListResponse => {
  210. if(baseListResponse.errorCode == 0){
  211. console.log(baseListResponse);
  212. }
  213. _self.checked = false;
  214. _self.loading=false;
  215. _self.getDatas();
  216. },
  217. errorData => {
  218. _self.loading=false;
  219. },
  220. );
  221. }
  222. },
  223. /**
  224. * 获取转移资产DTO集合
  225. */
  226. getAssetChangeDtos: function () {
  227. var _self = this;
  228. let assetChangeDtos = [];
  229. _self.assetChangeWaitDtos.forEach(function (item) {
  230. if (item.checked) {
  231. let assetChangeDto = {
  232. assetInstanceId: item.assetSimpleResponse.id,
  233. assetChangeWaitId: item.id,
  234. };
  235. assetChangeDtos.push(assetChangeDto);
  236. }
  237. });
  238. return assetChangeDtos;
  239. },
  240. /**
  241. * 冻结表头
  242. */
  243. fixedTableHeader: function () {
  244. let _self = this;
  245. _self.$nextTick(function () {
  246. $('#' + _self.tableId).tableFixer({ left: 3, head: true });
  247. });
  248. },
  249. },
  250. };
  251. </script>
  252. <style scoped>
  253. .grid-container {
  254. display: grid;
  255. grid-template-columns: 100%;
  256. grid-template-rows: auto 50px;
  257. height: 100%;
  258. width: 100%;
  259. align-items: end;
  260. }
  261. .grid-item-1 {
  262. padding-right: 20px;
  263. overflow: hidden;
  264. grid-row: 1/2;
  265. grid-column: 1 / 2;
  266. height: 100%;
  267. }
  268. .grid-item-2 {
  269. grid-row: 2/3;
  270. grid-column: 1 / 2;
  271. }
  272. .fixed-table {
  273. table-layout: fixed;
  274. width: 800px !important;
  275. min-width: 800px !important;
  276. }
  277. table.fixed-table tr {
  278. height: 40px;
  279. }
  280. table.fixed-table th,
  281. table.fixed-table td {
  282. overflow: hidden;
  283. white-space: nowrap;
  284. text-overflow: ellipsis;
  285. }
  286. </style>