ky-asset-list.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <basic-container>
  3. <avue-crud
  4. v-bind="bindVal"
  5. v-on="onEvent"
  6. v-model="form"
  7. :page.sync="page"
  8. :before-open="handleBeforeOpen"
  9. :permission="permissionList"
  10. >
  11. <template slot="menuLeft">
  12. <el-button
  13. v-if="!isSelAnnual"
  14. type="danger"
  15. size="small"
  16. icon="el-icon-delete"
  17. plain
  18. @click="handleDelete"
  19. >
  20. 删 除
  21. </el-button>
  22. <el-button
  23. v-if="!isSelAnnual"
  24. type="success"
  25. size="small"
  26. plain
  27. icon="el-icon-upload2"
  28. @click="handleImport"
  29. >
  30. 导入
  31. </el-button>
  32. <el-button
  33. type="warning"
  34. size="small"
  35. plain
  36. icon="el-icon-download"
  37. @click="handleExport"
  38. >
  39. 导出
  40. </el-button>
  41. <el-button
  42. v-if="!isSelAnnual"
  43. type="primary"
  44. size="small"
  45. plain
  46. @click="handleReadyLastMonData"
  47. >
  48. 读取上个月资产名单
  49. </el-button>
  50. <print-table-btn @click="printTable" />
  51. <div style="display: flex; align-items: center;">
  52. <year-month-select v-model="params.yearAndMonth"></year-month-select>
  53. </div>
  54. </template>
  55. <template slot-scope="{row}" slot="menu">
  56. <el-button v-if="[1,2].indexOf(row.status) > -1" type="text" size="mini" @click="handleChangeStatus(row, 0)">恢复</el-button>
  57. <el-button v-if="row.status === 0" type="text" size="mini" @click="handleChangeStatus(row, 1)">停用</el-button>
  58. <el-button v-if="row.status === 0" type="text" size="mini" @click="handleChangeStatus(row, 2)">已足额折旧</el-button>
  59. </template>
  60. <template slot="gl" slot-scope="{row}">
  61. <span v-if="'软件,专利,非专利技术'.indexOf(row.zclb) > -1">/</span>
  62. <span v-else>{{ row.gl }}</span>
  63. </template>
  64. <!-- <template slot="glForm" slot-scope="{row}">
  65. <el-input-number v-if="'软件,专利,非专利技术'.indexOf(row.zclb) === -1" type="number" />
  66. </template> -->
  67. <!-- 开始时间 -->
  68. <template slot="kssjSearch">
  69. <el-date-picker
  70. v-model="params.kssjRange"
  71. type="daterange"
  72. range-separator="至"
  73. start-placeholder="开始日期"
  74. end-placeholder="结束日期"
  75. value-format="yyyy-MM-dd"
  76. style="width: 240px !important;"
  77. >
  78. </el-date-picker>
  79. </template>
  80. <!-- 使用寿命 -->
  81. <template slot="sysmSearch">
  82. <div style="display: flex; align-items: center;">
  83. <span>使用寿命:</span>
  84. <avue-input-number v-model="params.startSysm" :min="0" style="width: 100px !important;"></avue-input-number>
  85. <span style="width: 20px; text-align: center;">至</span>
  86. <avue-input-number v-model="params.endSysm" :min="0" style="width: 100px !important;"></avue-input-number>
  87. </div>
  88. </template>
  89. </avue-crud>
  90. <upload-excel-dialog ref="uploadExcelDialog" :uploadAfter="uploadAfter"/>
  91. <WideTablePrinter
  92. ref="printWideTable"
  93. :columns="wideTableColumns"
  94. :data="data"
  95. :print-title="printTitle"
  96. :rows-per-page="30"
  97. :default-landscape="true"
  98. />
  99. </basic-container>
  100. </template>
  101. <script>
  102. import { getLastMonthData } from "@/api/basicResource/kyAssetList";
  103. import {exportBloByPost} from "@/api/common";
  104. import YearMonthSelect from "@/components/year-month-select";
  105. import UploadExcelDialog from "@/components/upload-excel-dialog";
  106. import moment from "moment";
  107. import {getToken} from "@/util/auth";
  108. import {downloadXls} from "@/util/util";
  109. export default window.$crudCommon({
  110. components: {
  111. YearMonthSelect,
  112. UploadExcelDialog,
  113. },
  114. data() {
  115. return {
  116. params: {
  117. yearAndMonth: moment(new Date()).format('YYYYMM'),
  118. },
  119. isSelAnnual: false, // 是否选择全年
  120. wideTableColumns: [],
  121. printTitle: "",
  122. };
  123. },
  124. watch: {
  125. 'params.yearAndMonth'(newVal) {
  126. if (newVal.length > 4) {
  127. // 是否勾选未全年
  128. this.isSelAnnual = false;
  129. } else {
  130. this.isSelAnnual = true;
  131. }
  132. this.page.currentPage = 1;
  133. this.getList(this.page);
  134. }
  135. },
  136. computed: {
  137. permissionList() {
  138. return {
  139. addBtn: !this.isSelAnnual,
  140. editBtn: !this.isSelAnnual,
  141. delBtn: !this.isSelAnnual,
  142. };
  143. },
  144. },
  145. mounted() {
  146. let newOption = { ...this.option };
  147. // 资产类别下拉框,设置监听事件
  148. newOption.column.forEach(item => {
  149. if (item.prop == "zclb") {
  150. item.change = ({ item }) => {
  151. if (!!item && "软件,专利权,非专利技术".indexOf(item.dictValue) > -1) {
  152. newOption.column[3].display = false;
  153. } else {
  154. newOption.column[3].display = true;
  155. }
  156. }
  157. }
  158. });
  159. this.option = { ...newOption };
  160. },
  161. methods: {
  162. searchChange(params, done) {
  163. if (done) done();
  164. if (this.validatenull(params)) {
  165. Object.keys(this.params).forEach(ele => {
  166. if (!['createTime_dategt', 'createTime_datelt', 'yearAndMonth', 'kssjRange', 'startSysm', 'endSysm'].includes(ele)) {
  167. delete this.params[ele];
  168. }
  169. })
  170. } else {
  171. Object.keys(params).forEach(ele => {
  172. if (this.validatenull(params[ele])) {
  173. delete this.params[ele];
  174. delete params[ele];
  175. }
  176. })
  177. }
  178. this.params = Object.assign(this.params, params);
  179. if (this.params.kssjRange && this.params.kssjRange.length) {
  180. this.params.startTime = this.params.kssjRange[0];
  181. this.params.endTime = this.params.kssjRange[1];
  182. }
  183. this.page.currentPage = 1;
  184. this.getList();
  185. },
  186. getFormData() {
  187. return { ...this.form, yearAndMonth: this.params.yearAndMonth };
  188. },
  189. getDelParams(row) {
  190. return [{ id: row.id, yearAndMonth: this.params.yearAndMonth }];
  191. },
  192. getBatchDelParams() {
  193. let delArr = [];
  194. this.data.forEach(item => {
  195. if (this.ids.indexOf(item.id) > -1) {
  196. delArr.push({ yearAndMonth: this.params.yearAndMonth, id: item.id });
  197. }
  198. });
  199. return delArr;
  200. },
  201. handleImport() {
  202. let excelParams = { yearAndMonth: this.params.yearAndMonth };
  203. this.$refs.uploadExcelDialog.open('/api//kd-scientific/asset/import', excelParams);
  204. },
  205. uploadAfter() {
  206. this.page.currentPage = 1;
  207. this.getList(this.page);
  208. },
  209. handleExport() {
  210. exportBloByPost(`/api//kd-scientific/asset/export-zc?${this.website.tokenHeader}=${getToken()}`, this.params).then(res => {
  211. downloadXls(res.data, `科研资产清单${this.params.yearAndMonth}.xlsx`);
  212. });
  213. },
  214. handleReadyLastMonData() {
  215. this.$confirm("确认要读取上个月的数据吗?", "提示", {
  216. confirmButtonText: "确定",
  217. cancelButtonText: "取消",
  218. type: "warning"
  219. }).then(() => {
  220. getLastMonthData({ yearAndMonth: this.params.yearAndMonth}).then(res => {
  221. let data = res.data;
  222. if (data.success) {
  223. this.$message.success('读取成功!');
  224. this.page.currentPage = 1;
  225. this.getList(this.page);
  226. }
  227. });
  228. });
  229. },
  230. handleChangeStatus(rowData, status) {
  231. let msgText = '';
  232. if (status === 0) {
  233. msgText = `确认恢复资产“${rowData.zcmc}”吗?`
  234. } else if (status === 1) {
  235. msgText = `确认停用资产“${rowData.zcmc}”吗?`
  236. } else if (status === 2) {
  237. msgText = `确认将资产“${rowData.zcmc}”设置为已足额折旧吗?`
  238. }
  239. this.$confirm(msgText, "提示", {
  240. confirmButtonText: "确定",
  241. cancelButtonText: "取消",
  242. type: "warning"
  243. }).then(() => {
  244. const params = { ...rowData, status };
  245. this.api.update(params).then(({ data }) => {
  246. if (data.success) {
  247. this.$message.success("操作成功!");
  248. this.getList(this.page);
  249. }
  250. });
  251. });
  252. },
  253. /**
  254. * 打印表格
  255. * @param isLandscape 是否横向打印
  256. */
  257. printTable(isLandscape) {
  258. this.wideTableColumns = this.$refs.crud.columnOption;
  259. this.printTitle = `科研资产清单${this.params.yearAndMonth}`;
  260. this.$nextTick(() => {
  261. this.$refs.printWideTable.printTable(isLandscape);
  262. })
  263. },
  264. },
  265. }, {
  266. // 模块路径
  267. name: 'basicResource/kyAssetList',
  268. res: ({ data }) => {
  269. return data;
  270. },
  271. });
  272. </script>