AssetByRfid.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. <template>
  2. <div class="grid-container">
  3. <div class="grid-item-1">
  4. <!-- <div class="col-md-12"> -->
  5. <!-- <div class="h2 pull-left">资产进出记录</div> -->
  6. <div>
  7. <Navbar
  8. :title="$t('lang.AssetByRfid.assetInAndOutRecords')"
  9. :is-go-back="false"
  10. style="margin-left: 14px"
  11. />
  12. </div>
  13. </div>
  14. <div class="grid-item-2">
  15. <form class="form-inline">
  16. <div class="form-group">
  17. <label style="margin-left: 14px">{{
  18. $t("lang.AssetByRfid.startTime")
  19. }}</label>
  20. <div style="float: right">
  21. <DateTime
  22. v-model="startDate"
  23. name="datetime"
  24. style="float: left"
  25. />
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label>{{ $t("lang.AssetByRfid.endTime") }}</label>
  30. <div style="float: right">
  31. <DateTime
  32. v-model="endDate"
  33. name="datetime"
  34. />
  35. </div>
  36. </div>
  37. <div class="form-group">
  38. <label>{{ $t("lang.AssetByRfid.storageLocation") }}</label>
  39. <div style="float: right">
  40. <SearchWidget
  41. :info-window-no="289190"
  42. :field="field"
  43. :field-value="fieldValue"
  44. :display-name="field.listFieldNames"
  45. :where-clause-source="whereClauseSource"
  46. @value-changed="valueChanged"
  47. />
  48. </div>
  49. </div>
  50. <button
  51. type="button"
  52. class="btn btn-default"
  53. style="margin-top: 1px"
  54. @click="search"
  55. >
  56. {{ $t("lang.AssetByRfid.determine") }}
  57. </button>
  58. <button
  59. type="button"
  60. class="btn btn-default"
  61. style="margin-top: 1px"
  62. @click="exportExcel"
  63. >
  64. {{ $t("lang.AssetByRfid.export") }}
  65. </button>
  66. </form>
  67. </div>
  68. <div class="grid-item-3">
  69. <div class="col-md-12 div-asset-info">
  70. <div class="form form-inline time-box">
  71. <div class="table-responsive">
  72. <table class="table table-striped table-bordered">
  73. <thead>
  74. <tr height="40px">
  75. <th>{{ $t("lang.AssetByRfid.serialNumber") }}</th>
  76. <th>{{ $t("lang.AssetByRfid.assetName") }}</th>
  77. <th>{{ $t("lang.AssetByRfid.assetNumber") }}</th>
  78. <th>{{ $t("lang.AssetByRfid.assetCategory") }}</th>
  79. <th>{{ $t("lang.AssetByRfid.assetEPC") }}</th>
  80. <th>{{ $t("lang.AssetByRfid.storageLocation") }}</th>
  81. <th>{{ $t("lang.AssetByRfid.startUseTime") }}</th>
  82. <th>{{ $t("lang.AssetByRfid.remarks") }}</th>
  83. </tr>
  84. </thead>
  85. <tbody>
  86. <tr v-for="(item, index) in assetInstances" :key="item.id">
  87. <td>{{ index + 1 }}</td>
  88. <td>{{ item.name }}</td>
  89. <td>{{ item.assetNo }}</td>
  90. <td>{{ item.category }}</td>
  91. <td>{{ item.epc }}</td>
  92. <td>{{ item.locationName }}</td>
  93. <td>{{ item.depreciationStartDate }}</td>
  94. <td>{{ item.description }}</td>
  95. </tr>
  96. </tbody>
  97. </table>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </template>
  104. <script>
  105. import Common from '../../common/Common.js';
  106. import { Notify } from 'pc-component-v3';
  107. export default {
  108. components: {
  109. },
  110. data: function () {
  111. return {
  112. startDate: undefined,
  113. endDate: undefined,
  114. locationId: null,
  115. assetInstances: [],
  116. field: {
  117. name: '',
  118. listFieldNames: 'location.name',
  119. },
  120. fieldValue: {
  121. id: null,
  122. displayValue: [''],
  123. fieldType: 'Key',
  124. },
  125. whereClauseSource: {
  126. customerDataDimensions:[{
  127. fieldName: 'o.id',
  128. dataDimensionTypeNo: '202201191700',
  129. defaultDataDimensionTypeValueNo: '1',
  130. }],
  131. },
  132. };
  133. },
  134. methods: {
  135. /**
  136. * 导出excel
  137. */
  138. exportExcel: function () {
  139. var _self = this;
  140. if (
  141. _self.assetInstances.length == 0 ||
  142. _self.assetInstances == undefined ||
  143. _self.assetInstances == null
  144. ) {
  145. Notify.error('提示', '当前无数据导出');
  146. return;
  147. }
  148. var loginInfo = localStorage.getItem('#LoginInfo');
  149. var loginData = JSON.parse(loginInfo);
  150. var locationId = _self.locationId;
  151. var whereClause = ' assetInstance.clientId=' + loginData.loginClientId;
  152. var str = '';
  153. var epcs = [];
  154. _self.assetInstances.forEach(function (ai) {
  155. epcs.push(ai.epc);
  156. });
  157. str = ' and ai.epc in ( ';
  158. for (var i = 0; i < epcs.length; i++) {
  159. if (i == epcs.length - 1) {
  160. str = str + epcs[i] + ' ) ';
  161. } else {
  162. str = str + epcs[i] + ' , ';
  163. }
  164. }
  165. if (locationId != null) {
  166. str = str + ' and ai.locationId = ' + locationId;
  167. }
  168. whereClause = whereClause + str;
  169. console.log(whereClause);
  170. whereClause = encodeURIComponent(whereClause);
  171. var url =
  172. '/ureport/preview?_u=dicfile-eam:AssetInstancetU2Report.ureport.xml&whereClause=' +
  173. whereClause;
  174. window.open(url);
  175. },
  176. /**
  177. * 存放地点选择事件
  178. * @param {Object} newFieldValue
  179. */
  180. valueChanged: function (newFieldValue) {
  181. console.log(newFieldValue);
  182. this.fieldValue = newFieldValue;
  183. this.locationId = newFieldValue.id;
  184. },
  185. /**
  186. * 搜索
  187. */
  188. search: function () {
  189. var _self = this;
  190. $.ajax({
  191. url: Common.getApiURL('AssetInstanceResource/getAssetByTime'),
  192. type: 'get',
  193. dataType: 'json',
  194. data: {
  195. startTime: _self.startDate,
  196. endTime: _self.endDate,
  197. locationId: _self.locationId,
  198. },
  199. beforeSend: function (request) {
  200. Common.addTokenToRequest(request);
  201. },
  202. success: function (data) {
  203. _self.assetInstances = data;
  204. },
  205. error: function (XMLHttpRequest, textStatus, errorThrown) {
  206. _self.loading=false;
  207. Common.processException(XMLHttpRequest, textStatus, errorThrown);
  208. },
  209. });
  210. },
  211. mounted: function () {
  212. this.startDate = '';
  213. this.endDate = '';
  214. this.search();
  215. },
  216. },
  217. };
  218. </script>
  219. <style scoped>
  220. .grid-container {
  221. display: grid;
  222. grid-template-rows: 8% 8% 84%;
  223. grid-template-columns: 100%;
  224. width: 100%;
  225. /*视口被均分为 100 单位的 vh 占据整个窗口,扣掉顶部 topNav 的距离后,计算得到 responseOrganizationSelect 的高度*/
  226. height: calc(100vh - 130px);
  227. margin-top: 10px;
  228. }
  229. .grid-item-1 {
  230. grid-row: 1/2;
  231. }
  232. .grid-item-2 {
  233. grid-row: 2/3;
  234. }
  235. .grid-item-3 {
  236. grid-row: 3/4;
  237. }
  238. .box {
  239. border: 1px #ccc solid;
  240. margin-bottom: 15px;
  241. padding-top: 10px;
  242. border-radius: 5px;
  243. background-color: #ffffff;
  244. }
  245. .label {
  246. float: left;
  247. }
  248. .div-form {
  249. margin-bottom: 10px;
  250. }
  251. </style>