AssetBatchOperationOrganization.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. <template>
  2. <div>
  3. <div class="grid-container">
  4. <div class="grid-item-1">
  5. <div>
  6. <Navbar
  7. :title="$t('lang.AssetBatchOperationOrganization.assetConfirmationBatchTransfer')"
  8. :is-go-back="true"
  9. />
  10. </div>
  11. </div>
  12. <div class="grid-item-2">
  13. <div class="row">
  14. <div class="col-md-12">
  15. <div class="form-inline">
  16. <div class="form-group">
  17. <label
  18. for="organizationName"
  19. style="width: 115px"
  20. >{{ $t('lang.AssetBatchOperationOrganization.ownerDepartmentAfterTransfer') }}</label>
  21. <SearchWidget
  22. :info-window-no="infoWindowNo"
  23. :field="organizationField"
  24. :field-value="organizationFieldValue"
  25. :display-name="organizationField.listDisplayFieldName"
  26. :where-clause-source="whereClauseSource"
  27. @value-changed="valueChanged"
  28. />
  29. </div>
  30. <div class="form-group">
  31. <label
  32. for="organizationName"
  33. style="width: 115px"
  34. >{{ $t('lang.AssetBatchOperationOrganization.ownerClientAfterTransfer') }}</label>
  35. <input
  36. v-model="organizationName"
  37. autocomplete="off"
  38. type="text"
  39. class="form-control"
  40. style="width: 236px"
  41. readonly
  42. />
  43. </div>
  44. <div class="form-group">
  45. <label
  46. for="organizationName"
  47. style="width: 115px"
  48. >{{ $t('lang.AssetBatchOperationOrganization.useDepartmentAfterTransfer') }}</label>
  49. <SearchWidget
  50. style="width: 236px;"
  51. :info-window-no="infoWindowNo"
  52. :field="responseOrganizationField"
  53. :field-value="responseOrganizationFieldValue"
  54. :display-name="responseOrganizationField.listDisplayFieldName"
  55. :where-clause-source="whereClauseSource"
  56. @value-changed="responsibilityValueChanged"
  57. />
  58. </div>
  59. <div class="form-group">
  60. <label
  61. for="organizationName"
  62. style="width: 115px"
  63. >{{ $t('lang.AssetBatchOperationOrganization.useClientAfterTransfer') }}</label>
  64. <input
  65. v-model="responsibilityOrganizationName"
  66. autocomplete="off"
  67. type="text"
  68. class="form-control"
  69. style="width: 236px"
  70. readonly
  71. />
  72. </div>
  73. <div class="form-group">
  74. <label
  75. for="organizationName"
  76. style="width: 115px"
  77. >{{ $t('lang.AssetBatchOperationOrganization.newStorageLocation') }}</label>
  78. <SearchWidget
  79. style="width: 236px;"
  80. :info-window-no="locationInfoWindowNo"
  81. :field="locationField"
  82. :field-value="locationFieldValue"
  83. :display-name="locationField.listDisplayFieldName"
  84. :where-clause-source="locationWhereClauseSource"
  85. @value-changed="locationValueChanged"
  86. />
  87. </div>
  88. <div class="form-group">
  89. <label
  90. for="userName"
  91. style="width: 115px"
  92. >{{ $t('lang.AssetBatchOperationOrganization.personHhandlingAParticularTask') }}</label>
  93. <SearchWidget
  94. style="width: 236px;"
  95. :info-window-no="userWindowNo"
  96. :field="userField"
  97. :field-value="userFieldValue"
  98. :display-name="userField.listDisplayFieldName"
  99. :where-clause-source="clientIdWhereClauseSource"
  100. @value-changed="userValueChanged"
  101. />
  102. </div>
  103. <div class="form-group">
  104. <label
  105. for="reason"
  106. style="width: 115px"
  107. >{{ $t('lang.AssetBatchOperationOrganization.reasonsForTransfer') }}</label>
  108. <input
  109. id="reason"
  110. v-model="reason"
  111. autocomplete="off"
  112. type="text"
  113. class="form-control"
  114. style="width: 236px"
  115. :placeholder="$t('lang.AssetBatchOperationOrganization.pleaseFillInTheReasonForTransfer')"
  116. />
  117. </div>
  118. <div
  119. class="form-group"
  120. style="margin-top: 5px"
  121. >
  122. <button
  123. class="btn btn-primary"
  124. @click="resetQuery"
  125. >
  126. {{ $t('lang.AssetBatchOperationOrganization.query') }}
  127. </button>
  128. <button
  129. type="button"
  130. class="btn btn-success"
  131. @click="removeAssetChangeWaitDtos"
  132. >
  133. {{ $t('lang.AssetBatchOperationOrganization.cancelTransfer') }}
  134. </button>
  135. <button
  136. type="button"
  137. class="btn btn-info"
  138. style="text-align: right"
  139. @click="saveAssetChangeWaitDtos"
  140. >
  141. {{ $t('lang.AssetBatchOperationOrganization.generateDepartmentChangeDocument') }}
  142. </button>
  143. <span v-if="assetConfigDto.allowOrganizationBatchChange">
  144. <button
  145. type="button"
  146. class="btn btn-success"
  147. @click="generateAssetAllocate()"
  148. >
  149. {{ $t('lang.AssetBatchOperationOrganization.generateAssetTransferDocument') }}
  150. </button>
  151. </span>
  152. </div>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. <div class="grid-item-3">
  158. <AssetBatchOperationQueue
  159. ref="assetBatchOperationQueue"
  160. :change-type="changeType"
  161. />
  162. </div>
  163. </div>
  164. <Loading v-if="loading" />
  165. </div>
  166. </template>
  167. <script>
  168. import ClientResource from '../../api/base/ClientResource.js';
  169. import AssetChangeResource from '../../api/asset/AssetChangeResource.js';
  170. import AssetConfigResource from '../../api/asset/AssetConfigResource.js';
  171. import Common from '../../common/Common.js';
  172. import AssetAllocateResource from '../../api/asset/AssetAllocateResource.js';
  173. import AssetBatchOperationQueue from './AssetBatchOperationQueue.vue';
  174. import { Notify, Uuid } from 'pc-component-v3';
  175. export default {
  176. components: {
  177. AssetBatchOperationQueue,
  178. },
  179. data: function () {
  180. return {
  181. changeType: 'organizationChange',
  182. assetConfigDto: [], //固定资产设置Dto
  183. pagination: {
  184. total: 0,
  185. per_page: Common.pageSize, // required
  186. current_page: 1, // required
  187. last_page: 0, // required
  188. },
  189. infoWindowNo: '279750',
  190. whereClauseSource: {
  191. customerDataDimensions:[{
  192. fieldName: 'client.id',
  193. dataDimensionTypeNo: '202201191757',
  194. defaultDataDimensionTypeValueNo: '3',
  195. }],
  196. },
  197. locationInfoWindowNo: 109494,
  198. locationWhereClauseSource: {
  199. customerDataDimensions:[{
  200. fieldName: 'client.id',
  201. dataDimensionTypeNo: '202201191757',
  202. defaultDataDimensionTypeValueNo: '3',
  203. }],
  204. },
  205. clientIdWhereClauseSource: {
  206. customerDataDimensions:[{
  207. fieldName: 'client.id',
  208. dataDimensionTypeNo: '202201191757',
  209. defaultDataDimensionTypeValueNo: '3',
  210. }],
  211. },
  212. userWindowNo: '050408',
  213. organizationField: {
  214. name: '',
  215. listDisplayFieldName: 'name',
  216. },
  217. responseOrganizationField: {
  218. name: '',
  219. listDisplayFieldName: 'name',
  220. },
  221. locationField: {
  222. name: '',
  223. listDisplayFieldName: 'ar.name',
  224. },
  225. userField: {
  226. name: '',
  227. listDisplayFieldName: 'name',
  228. },
  229. organizationFieldValue: {
  230. id: null,
  231. displayValue: [''],
  232. fieldType: 'Key',
  233. },
  234. responseOrganizationFieldValue: {
  235. id: null,
  236. displayValue: [''],
  237. fieldType: 'Key',
  238. },
  239. locationFieldValue: {
  240. id: null,
  241. displayValue: [''],
  242. fieldType: 'Key',
  243. },
  244. userFieldValue: {
  245. id: null,
  246. displayValue: [''],
  247. fieldType: 'Key',
  248. },
  249. checked: false,
  250. reason: '',
  251. locationList: [],
  252. locationId: undefined,
  253. locationSelected: undefined,
  254. organizationName: undefined,
  255. responsibilityOrganizationName: undefined,
  256. loading: false,
  257. };
  258. },
  259. mounted: function () {
  260. var _self = this;
  261. _self.queryAssetConfig();
  262. _self.$refs.assetBatchOperationQueue.getDatas();
  263. },
  264. methods: {
  265. /**
  266. * 重置分页,然后查询
  267. */
  268. resetQuery: function () {
  269. var _self = this;
  270. _self.pagination.current_page = 1;
  271. _self.$refs.assetBatchOperationQueue.getDatas();
  272. },
  273. /**
  274. * 查询AssetConfigDto
  275. * @return {[type]} [description]
  276. */
  277. queryAssetConfig: function () {
  278. var _self = this;
  279. AssetConfigResource.queryAssetConfig().then(
  280. successData => {
  281. if(successData.errorCode == 0) {
  282. _self.assetConfigDto = successData.data;
  283. } else {
  284. Notify.error('提示',successData.errorMessage, false);
  285. }
  286. },
  287. errorData => { },
  288. );
  289. },
  290. // 使用部门选择框change事件
  291. valueChanged: function (newFieldValue) {
  292. var _self = this;
  293. this.organizationFieldValue = newFieldValue;
  294. _self.queryClient();
  295. },
  296. //所属部门选择框change事件
  297. responsibilityValueChanged: function (newResponsibilityFieldValue) {
  298. var _self = this;
  299. this.responseOrganizationFieldValue = newResponsibilityFieldValue;
  300. _self.queryResponsibilityClient();
  301. },
  302. /**
  303. * 存放地点选择框change事件
  304. */
  305. locationValueChanged: function (newResponsibilityFieldValue) {
  306. var _self = this;
  307. this.locationFieldValue = newResponsibilityFieldValue;
  308. },
  309. /**
  310. * 调拨经手人框change事件
  311. */
  312. userValueChanged: function (newResponsibilityFieldValue) {
  313. var _self = this;
  314. this.userFieldValue = newResponsibilityFieldValue;
  315. },
  316. /**
  317. * 根据使用部门Id查询所属单位
  318. */
  319. queryClient: function () {
  320. var _self = this;
  321. var organizationId = _self.organizationFieldValue.id;
  322. ClientResource.uniqueByOrganizationId(
  323. organizationId,
  324. ).then(
  325. baseObjectResponse => {
  326. if(baseObjectResponse.errorCode == 0){
  327. _self.organizationName = baseObjectResponse.data.name;
  328. }else{
  329. Notify.error('提示',baseObjectResponse.errorMessage, false);
  330. }
  331. },
  332. errorData => { },
  333. );
  334. },
  335. /**
  336. * 根据所属部门Id查询所属单位
  337. */
  338. queryResponsibilityClient: function () {
  339. var _self = this;
  340. var organizationId = _self.responseOrganizationFieldValue.id;
  341. ClientResource.uniqueByOrganizationId(
  342. organizationId,
  343. ).then(
  344. baseObjectResponse => {
  345. if(baseObjectResponse.errorCode == 0){
  346. _self.responsibilityOrganizationName = baseObjectResponse.data.name;
  347. }else{
  348. Notify.error('提示',baseObjectResponse.errorMessage, false);
  349. }
  350. },
  351. errorData => { },
  352. );
  353. },
  354. /**
  355. * 删除队列数据
  356. */
  357. removeAssetChangeWaitDtos: function () {
  358. this.$refs.assetBatchOperationQueue.removeAssetChangeWaitDtos();
  359. },
  360. /**
  361. * 获取转移资产DTO集合
  362. */
  363. getAssetChangeDtos: function () {
  364. var _self = this;
  365. let organizationId = null;
  366. let responseOrganizationId = null;
  367. let locationId = null;
  368. let responsibleUserId = null;
  369. if (_self.organizationFieldValue == undefined || _self.organizationFieldValue.id == undefined) {
  370. Notify.error('错误', '请选择转移后的所属部门。', true);
  371. return;
  372. } else {
  373. organizationId = _self.organizationFieldValue.id;
  374. }
  375. if (_self.responseOrganizationFieldValue == undefined ||
  376. _self.responseOrganizationFieldValue.id == undefined) {
  377. Notify.error('错误', '请选择转移后的使用部门。', true);
  378. return;
  379. } else {
  380. responseOrganizationId = _self.responseOrganizationFieldValue.id;
  381. }
  382. if(_self.reason == null || _self.reason == ''){
  383. Notify.error('错误', '转移原因不能为空。', true);
  384. return;
  385. }
  386. if (_self.locationFieldValue != null && _self.locationFieldValue.id != null) {
  387. locationId = _self.locationFieldValue.id;
  388. }
  389. if (_self.userFieldValue != null && _self.userFieldValue.id != null) {
  390. responsibleUserId = _self.userFieldValue.id;
  391. }
  392. var assetChangeDtos = _self.$refs.assetBatchOperationQueue.getAssetChangeDtos();
  393. if (assetChangeDtos != null) {
  394. assetChangeDtos.forEach(function (item) {
  395. item.organizationId = organizationId;
  396. item.responseOrganizationId = responseOrganizationId;
  397. item.reason = _self.reason;
  398. item.locationId = locationId;
  399. item.responsibleUserInId = responsibleUserId;
  400. });
  401. }
  402. return assetChangeDtos;
  403. },
  404. /**
  405. * 确认转移,生成部门变动单
  406. */
  407. saveAssetChangeWaitDtos: function () {
  408. var _self = this;
  409. let assetChangeDtos = _self.getAssetChangeDtos();
  410. if (assetChangeDtos == null) {
  411. return;
  412. }
  413. if (assetChangeDtos.length < 1) {
  414. Common.showDialog('提示', '请在表格中勾选待变动数据后再提交。', 'error');
  415. return;
  416. }
  417. _self.loading=true;
  418. AssetChangeResource.saveAssetChanges(assetChangeDtos).then(
  419. baseListResponse => {
  420. if(baseListResponse.errorCode == 0){
  421. _self.message = '共计' + baseListResponse.datas.length + '条资产数据变动成功。';
  422. Common.showDialog('提示', _self.message, 'success');
  423. if (baseListResponse.datas.length > 0) {
  424. let url = Common.getRedirectUrl(
  425. '#/desktop/window/041208?currPage=1&uuid=' +
  426. Uuid.createUUID(),
  427. );
  428. window.open(url);
  429. }
  430. }else{
  431. Common.showDialog('提示', baseListResponse.errorMessage, 'error');
  432. }
  433. _self.checked = false;
  434. _self.loading=false;
  435. _self.$refs.assetBatchOperationQueue.getDatas();
  436. },
  437. errorData => {
  438. _self.loading=false;
  439. Common.processException(errorData);
  440. },
  441. );
  442. },
  443. /**
  444. * 生成调拨单
  445. *
  446. */
  447. generateAssetAllocate: function () {
  448. var _self = this;
  449. let assetChangeDtos = _self.getAssetChangeDtos();
  450. if (assetChangeDtos == null) {
  451. return;
  452. }
  453. if (assetChangeDtos.length < 1) {
  454. Common.showDialog('提示', '请在表格中勾选待变动数据后再提交。', 'error');
  455. return;
  456. }
  457. _self.loading=true;
  458. AssetAllocateResource.generate(assetChangeDtos).then(
  459. baseListResponse => {
  460. _self.loading=false;
  461. _self.checked = false;
  462. _self.$refs.assetBatchOperationQueue.getDatas();
  463. if(baseListResponse.errorCode == 0){
  464. if (baseListResponse.datas.length > 0) {
  465. let url = Common.getRedirectUrl(
  466. '#/desktop/window/041601?currPage=1&uuid=' +
  467. Uuid.createUUID(),
  468. );
  469. window.open(url);
  470. }
  471. }
  472. },
  473. errorData => {
  474. _self.loading=false;
  475. Common.processException(errorData);
  476. },
  477. );
  478. },
  479. },
  480. };
  481. </script>
  482. <style scoped>
  483. .grid-container {
  484. display: grid;
  485. grid-template-columns: 100%;
  486. grid-template-rows: 80px min-content auto;
  487. /*视口被均分为 100 单位的 vh 占据整个窗口,扣掉顶部 topNav 的距离后,计算得到 responseOrganizationSelect 的高度*/
  488. height: calc(100vh - 80px);
  489. width: 100%;
  490. }
  491. .grid-item-1 {
  492. grid-column: 1 / 2;
  493. }
  494. .grid-item-2 {
  495. grid-column: 1 / 2;
  496. padding-bottom: 10px;
  497. }
  498. .grid-item-3 {
  499. padding-right: 20px;
  500. overflow: auto;
  501. grid-row: 3/4;
  502. grid-column: 1 / 2;
  503. height: 100%;
  504. }
  505. </style>