AssetBatchOperationQueue.vue 9.6 KB

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