index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item :label="$t('资产类别')" prop="assetclass"label-width="50">
  5. <el-input
  6. v-model="queryParams.assetclass"
  7. :placeholder="$t('请输入') + $t('资产类别')"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item :label="$t('资产编号')" prop="assetno" label-width="50">
  14. <el-input
  15. v-model="queryParams.assetno"
  16. :placeholder="$t('请输入') + $t('资产编号')"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item :label="$t('资本化时间')" label-width="50" prop="capitalizedon">
  23. <el-date-picker
  24. v-model="chooseDate"
  25. type="daterange"
  26. align="right"
  27. unlink-panels
  28. :range-separator="$t('至')"
  29. :start-placeholder="$t('开始日期')"
  30. :end-placeholder="$t('结束日期')"
  31. value-format="yyyy-MM-dd"
  32. :picker-options="pickerOptions">
  33. </el-date-picker>
  34. </el-form-item>
  35. <el-form-item>
  36. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">{{ $t('搜索') }}</el-button>
  37. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('重置') }}</el-button>
  38. </el-form-item>
  39. </el-form>
  40. <el-row :gutter="10" class="mb8">
  41. <el-col :span="1.5">
  42. <el-button
  43. type="primary"
  44. icon="el-icon-plus"
  45. size="mini"
  46. @click="handleAdd"
  47. v-hasPermi="['reliability:assetlist:add']"
  48. >{{ $t('新增') }}</el-button>
  49. </el-col>
  50. <el-col :span="1.5">
  51. <el-button
  52. type="success"
  53. icon="el-icon-edit"
  54. size="mini"
  55. :disabled="single"
  56. @click="handleUpdate"
  57. v-hasPermi="['reliability:assetlist:edit']"
  58. >{{ $t('修改') }}</el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. icon="el-icon-delete"
  64. size="mini"
  65. :disabled="multiple"
  66. @click="handleDelete"
  67. v-hasPermi="['reliability:assetlist:remove']"
  68. >{{ $t('删除') }}</el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="info"
  73. icon="el-icon-upload2"
  74. size="mini"
  75. @click="handleImport"
  76. v-hasPermi="['reliability:assetlist:edit']"
  77. >{{ $t('导入') }}</el-button>
  78. </el-col>
  79. <el-col :span="1.5">
  80. <el-button
  81. type="warning"
  82. icon="el-icon-download"
  83. size="mini"
  84. @click="handleExport"
  85. v-hasPermi="['reliability:assetlist:export']"
  86. >{{ $t('导出') }}</el-button>
  87. </el-col>
  88. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  89. </el-row>
  90. <el-table v-loading="loading" :data="assetlistList" @selection-change="handleSelectionChange" :height="clientHeight" border>
  91. <el-table-column type="selection" width="55" align="center" />
  92. <el-table-column :label="$t('序号')" align="center" prop="serialnumber" :show-overflow-tooltip="true"/>
  93. <el-table-column :label="$t('资产类别')" align="center" prop="assetclass" :show-overflow-tooltip="true"/>
  94. <el-table-column :label="$t('资产编号')" align="center" prop="assetno" :show-overflow-tooltip="true"/>
  95. <el-table-column :label="$t('参考')" align="center" prop="assetnoref" :show-overflow-tooltip="true"/>
  96. <el-table-column :label="$t('成本中心')" align="center" prop="costcenter" :show-overflow-tooltip="true"/>
  97. <el-table-column :label="$t('资本化时间')" align="center" prop="capitalizedon" width="100">
  98. <template slot-scope="scope">
  99. <span>{{ parseTime(scope.row.capitalizedon, '{y}-{m}-{d}') }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column :label="$t('描述')" align="center" prop="description" width="200" :show-overflow-tooltip="true"/>
  103. <el-table-column :label="$t('责任人')" align="center" prop="responsible" :show-overflow-tooltip="true"/>
  104. <el-table-column :label="$t('房间')" align="center" prop="room" :show-overflow-tooltip="true"/>
  105. <el-table-column :label="$t('位号')" align="center" prop="tagno" :show-overflow-tooltip="true"/>
  106. <el-table-column :label="$t('清查结果')" align="center" prop="assetresult" :show-overflow-tooltip="true"/>
  107. <el-table-column :label="$t('说明事项')" align="center" prop="comments" :show-overflow-tooltip="true"/>
  108. <el-table-column :label="$t('经理')" align="center" prop="ccmanager" :show-overflow-tooltip="true"/>
  109. <el-table-column label="BU" align="center" prop="bu" :show-overflow-tooltip="true"/>
  110. <el-table-column :label="$t('备注')" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  111. <el-table-column :label="$t('操作')" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  112. <template slot-scope="scope">
  113. <el-button
  114. size="mini"
  115. type="text"
  116. icon="el-icon-edit"
  117. @click="handleUpdate(scope.row)"
  118. v-hasPermi="['reliability:assetlist:edit']"
  119. >{{ $t('修改') }}</el-button>
  120. <el-button
  121. size="mini"
  122. type="text"
  123. icon="el-icon-delete"
  124. @click="handleDelete(scope.row)"
  125. v-hasPermi="['reliability:assetlist:remove']"
  126. >{{ $t('删除') }}</el-button>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <pagination
  131. v-show="total>0"
  132. :total="total"
  133. :page.sync="queryParams.pageNum"
  134. :limit.sync="queryParams.pageSize"
  135. @pagination="getList"
  136. />
  137. <!-- 添加或修改资产清单对话框 -->
  138. <el-dialog v-dialogDrag :title="title" :visible.sync="open" width="500px" append-to-body>
  139. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  140. <el-form-item :label="$t('装置名称')" prop="plantCode">
  141. <el-select v-model="form.plantCode" :placeholder="$t('请选择') + $t('装置名称')">
  142. <el-option
  143. v-for="dict in plantCodeOptions"
  144. :key="dict.dictValue"
  145. :label="dict.dictLabel"
  146. :value="dict.dictValue"
  147. ></el-option>
  148. </el-select>
  149. </el-form-item>
  150. <el-form-item :label="$t('序号')" prop="serialnumber">
  151. <el-input v-model="form.serialnumber" :placeholder="$t('请输入') + $t('序号')" />
  152. </el-form-item>
  153. <el-form-item :label="$t('资产类别')" prop="assetclass">
  154. <el-input v-model="form.assetclass" :placeholder="$t('请输入') + $t('资产类别')" />
  155. </el-form-item>
  156. <el-form-item :label="$t('资产编号')" prop="assetno">
  157. <el-input v-model="form.assetno":placeholder="$t('请输入') + $t('资产编号')" />
  158. </el-form-item>
  159. <el-form-item :label="$t('参考')" prop="assetnoref">
  160. <el-input v-model="form.assetnoref" :placeholder="$t('请输入') + $t('参考')" />
  161. </el-form-item>
  162. <el-form-item :label="$t('成本中心')" prop="costcenter">
  163. <el-input v-model="form.costcenter" :placeholder="$t('请输入') + $t('成本中心')" />
  164. </el-form-item>
  165. <el-form-item :label="$t('资本化时间')" prop="capitalizedon">
  166. <el-date-picker clearable size="small" style="width: 200px"
  167. v-model="form.capitalizedon"
  168. type="date"
  169. value-format="yyyy-MM-dd"
  170. :placeholder="$t('请选择') + $t('资本化时间')">
  171. </el-date-picker>
  172. </el-form-item>
  173. <el-form-item :label="$t('描述')" prop="description">
  174. <el-input v-model="form.description" :placeholder="$t('请输入') + $t('描述')" />
  175. </el-form-item>
  176. <el-form-item :label="$t('责任人')" prop="responsible">
  177. <el-input v-model="form.responsible" :placeholder="$t('请输入') + $t('责任人')" />
  178. </el-form-item>
  179. <el-form-item :label="$t('房间')" prop="room">
  180. <el-input v-model="form.room" :placeholder="$t('请输入') + $t('房间')" />
  181. </el-form-item>
  182. <el-form-item :label="$t('位号')" prop="tagno">
  183. <el-input v-model="form.tagno" :placeholder="$t('请输入') + $t('位号')" />
  184. </el-form-item>
  185. <el-form-item :label="$t('清查结果')" prop="assetresult">
  186. <el-input v-model="form.assetresult" :placeholder="$t('请输入') + $t('清查结果')" />
  187. </el-form-item>
  188. <el-form-item :label="$t('说明事项')" prop="comments">
  189. <el-input v-model="form.comments" :placeholder="$t('请输入') + $t('说明事项')" />
  190. </el-form-item>
  191. <el-form-item :label="$t('经理')" prop="ccmanager">
  192. <el-input v-model="form.ccmanager" :placeholder="$t('请输入') + $t('经理')" />
  193. </el-form-item>
  194. <el-form-item label="BU" prop="bu">
  195. <el-input v-model="form.bu" :placeholder="$t('请输入') + 'BU'" />
  196. </el-form-item>
  197. <el-form-item :label="$t('备注')" prop="remarks">
  198. <el-input v-model="form.remarks" :placeholder="$t('请输入') + $t('备注')" />
  199. </el-form-item>
  200. <el-form-item :label="$t('归属部门')" prop="deptId">
  201. <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" :placeholder="$t('请选择') + $t('归属部门')" />
  202. </el-form-item>
  203. </el-form>
  204. <div slot="footer" class="dialog-footer">
  205. <el-button type="primary" @click="submitForm">{{ $t('确 定') }}</el-button>
  206. <el-button @click="cancel">{{ $t('取 消') }}</el-button>
  207. </div>
  208. </el-dialog>
  209. <!-- 用户导入对话框 -->
  210. <el-dialog v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  211. <el-upload
  212. ref="upload"
  213. :limit="1"
  214. accept=".xlsx, .xls"
  215. :headers="upload.headers"
  216. :action="upload.url"
  217. :disabled="upload.isUploading"
  218. :on-progress="handleFileUploadProgress"
  219. :on-success="handleFileSuccess"
  220. :auto-upload="false"
  221. drag
  222. >
  223. <i class="el-icon-upload"></i>
  224. <div class="el-upload__text">
  225. {{ $t('将文件拖到此处,或') }}
  226. <em>{{ $t('点击上传') }}</em>
  227. </div>
  228. <div class="el-upload__tip" slot="tip">
  229. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  230. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  231. </div>
  232. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  233. <input name="type" :value="upload.type" hidden />
  234. </form>
  235. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  236. </el-upload>
  237. <div slot="footer" class="dialog-footer">
  238. <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
  239. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  240. </div>
  241. </el-dialog>
  242. </div>
  243. </template>
  244. <script>
  245. import { listAssetlist, getAssetlist, delAssetlist, addAssetlist, updateAssetlist, exportAssetlist } from "@/api/reliability/assetlist";
  246. import { treeselect } from "@/api/system/dept";
  247. import { getToken } from "@/utils/auth";
  248. import Treeselect from "@riophae/vue-treeselect";
  249. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  250. export default {
  251. name: "Assetlist",
  252. components: { Treeselect },
  253. data() {
  254. return {
  255. // 遮罩层
  256. loading: true,
  257. // 选中数组
  258. ids: [],
  259. // 非单个禁用
  260. single: true,
  261. // 非多个禁用
  262. multiple: true,
  263. // 显示搜索条件
  264. showSearch: false,
  265. // 总条数
  266. total: 0,
  267. // 资产清单表格数据
  268. assetlistList: [],
  269. // 弹出层标题
  270. title: "",
  271. // 部门树选项
  272. deptOptions: undefined,
  273. clientHeight:300,
  274. // 是否显示弹出层
  275. open: false,
  276. // 装置名称字典
  277. plantCodeOptions: [],
  278. // 用户导入参数
  279. upload: {
  280. //下载模板请求地址
  281. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  282. //下载模板类型
  283. type: "assetlist",
  284. // 是否显示弹出层(用户导入)
  285. open: false,
  286. // 弹出层标题(用户导入)
  287. title: "",
  288. // 是否禁用上传
  289. isUploading: false,
  290. // 是否更新已经存在的用户数据
  291. updateSupport: 0,
  292. // 设置上传的请求头部
  293. headers: { Authorization: "Bearer " + getToken() },
  294. // 上传的地址
  295. url: process.env.VUE_APP_BASE_API + "/reliability/assetlist/importData"
  296. },
  297. // 查询参数
  298. queryParams: {
  299. pageNum: 1,
  300. pageSize: 20,
  301. assetclass: null,
  302. assetno: null,
  303. capitalizedon: null,
  304. startDate: null,
  305. endDate: null
  306. },
  307. //日期快速选择
  308. pickerOptions: {
  309. shortcuts: [{
  310. text: this.$t('最近一周'),
  311. onClick(picker) {
  312. const end = new Date();
  313. const start = new Date();
  314. start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
  315. picker.$emit('pick', [start, end]);
  316. }
  317. }, {
  318. text: this.$t('最近一个月'),
  319. onClick(picker) {
  320. const end = new Date();
  321. const start = new Date();
  322. start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
  323. picker.$emit('pick', [start, end]);
  324. }
  325. }, {
  326. text: this.$t('最近三个月'),
  327. onClick(picker) {
  328. const end = new Date();
  329. const start = new Date();
  330. start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
  331. picker.$emit('pick', [start, end]);
  332. }
  333. }]
  334. },
  335. //日期选择器
  336. chooseDate: [],
  337. // 表单参数
  338. form: {},
  339. // 表单校验
  340. rules: {
  341. plantCode: [
  342. { required: true, message: this.$t('装置名称') + this.$t('不能为空'), trigger: "change" }
  343. ],
  344. serialnumber: [
  345. { required: true, message: this.$t('序号') + this.$t('不能为空'), trigger: "blur" }
  346. ],
  347. assetclass: [
  348. { required: true, message: this.$t('资产类别') + this.$t('不能为空'), trigger: "blur" }
  349. ],
  350. assetno: [
  351. { required: true, message: this.$t('资产编号') + this.$t('不能为空'), trigger: "blur" }
  352. ],
  353. deptId: [
  354. { required: true, message: this.$t('部门编号') + this.$t('不能为空'), trigger: "blur" }
  355. ]
  356. }
  357. };
  358. },
  359. watch: {
  360. // 根据名称筛选部门树
  361. deptName(val) {
  362. this.$refs.tree.filter(val);
  363. }
  364. },
  365. created() {
  366. //设置表格高度对应屏幕高度
  367. this.$nextTick(() => {
  368. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  369. })
  370. this.getList();
  371. this.getTreeselect();
  372. this.getDicts("PLANT_DIVIDE").then(response => {
  373. this.plantCodeOptions = response.data;
  374. });
  375. },
  376. methods: {
  377. /** 查询资产清单列表 */
  378. getList() {
  379. this.loading = true;
  380. listAssetlist(this.queryParams).then(response => {
  381. this.assetlistList = response.rows;
  382. this.total = response.total;
  383. this.loading = false;
  384. });
  385. },
  386. /** 查询部门下拉树结构 */
  387. getTreeselect() {
  388. treeselect().then(response => {
  389. this.deptOptions = response.data;
  390. });
  391. },
  392. // 装置名称字典翻译
  393. plantCodeFormat(row, column) {
  394. return this.selectDictLabel(this.plantCodeOptions, row.plantCode);
  395. },
  396. // 取消按钮
  397. cancel() {
  398. this.open = false;
  399. this.reset();
  400. },
  401. // 表单重置
  402. reset() {
  403. this.form = {
  404. id: null,
  405. plantCode: null,
  406. serialnumber: null,
  407. assetclass: null,
  408. assetno: null,
  409. assetnoref: null,
  410. costcenter: null,
  411. capitalizedon: null,
  412. description: null,
  413. responsible: null,
  414. room: null,
  415. tagno: null,
  416. assetresult: null,
  417. comments: null,
  418. ccmanager: null,
  419. bu: null,
  420. delFlag: null,
  421. createrCode: null,
  422. createdate: null,
  423. updaterCode: null,
  424. updatedate: null,
  425. remarks: null,
  426. deptId: null,
  427. startDate: null,
  428. endDate: null
  429. };
  430. this.resetForm("form");
  431. },
  432. /** 搜索按钮操作 */
  433. handleQuery() {
  434. this.queryParams.pageNum = 1;
  435. this.queryParams.startDate = this.chooseDate[0];
  436. this.queryParams.endDate = this.chooseDate[1];
  437. this.getList();
  438. },
  439. /** 重置按钮操作 */
  440. resetQuery() {
  441. this.resetForm("queryForm");
  442. this.chooseDate = "";
  443. this.handleQuery();
  444. },
  445. // 多选框选中数据
  446. handleSelectionChange(selection) {
  447. this.ids = selection.map(item => item.id)
  448. this.single = selection.length!==1
  449. this.multiple = !selection.length
  450. },
  451. /** 新增按钮操作 */
  452. handleAdd() {
  453. this.reset();
  454. this.open = true;
  455. this.title = this.$t('新增') + " " + this.$t('资产清单');
  456. },
  457. /** 修改按钮操作 */
  458. handleUpdate(row) {
  459. this.reset();
  460. const id = row.id || this.ids
  461. getAssetlist(id).then(response => {
  462. this.form = response.data;
  463. this.open = true;
  464. this.title = this.$t('修改') + this.$t('资产清单');
  465. });
  466. },
  467. /** 提交按钮 */
  468. submitForm() {
  469. this.$refs["form"].validate(valid => {
  470. if (valid) {
  471. if (this.form.id != null) {
  472. updateAssetlist(this.form).then(response => {
  473. this.msgSuccess(this.$t('修改成功'));
  474. this.open = false;
  475. this.getList();
  476. });
  477. } else {
  478. addAssetlist(this.form).then(response => {
  479. this.msgSuccess(this.$t('新增成功'));
  480. this.open = false;
  481. this.getList();
  482. });
  483. }
  484. }
  485. });
  486. },
  487. /** 删除按钮操作 */
  488. handleDelete(row) {
  489. const ids = row.id || this.ids;
  490. this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
  491. confirmButtonText: this.$t('确定'),
  492. cancelButtonText: this.$t('取消'),
  493. type: "warning"
  494. }).then(function() {
  495. return delAssetlist(ids);
  496. }).then(() => {
  497. this.getList();
  498. this.msgSuccess(this.$t('删除成功'));
  499. })
  500. },
  501. /** 导出按钮操作 */
  502. handleExport() {
  503. const queryParams = this.queryParams;
  504. this.$confirm(this.$t('是否确认导出所有资产清单数据项?'), this.$t('警告'), {
  505. confirmButtonText: this.$t('确定'),
  506. cancelButtonText: this.$t('取消'),
  507. type: "warning"
  508. }).then(function() {
  509. return exportAssetlist(queryParams);
  510. }).then(response => {
  511. this.download(response.msg);
  512. })
  513. },
  514. /** 导入按钮操作 */
  515. handleImport() {
  516. this.upload.title = this.$t('用户导入');
  517. this.upload.open = true;
  518. },
  519. /** 下载模板操作 */
  520. importTemplate() {
  521. this.$refs['downloadFileForm'].submit()
  522. },
  523. // 文件上传中处理
  524. handleFileUploadProgress(event, file, fileList) {
  525. this.upload.isUploading = true;
  526. },
  527. // 文件上传成功处理
  528. handleFileSuccess(response, file, fileList) {
  529. this.upload.open = false;
  530. this.upload.isUploading = false;
  531. this.$refs.upload.clearFiles();
  532. if (response.data[0] != null) {
  533. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败')+"。", this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  534. }else {
  535. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), { dangerouslyUseHTMLString: true });
  536. }
  537. this.getList();
  538. },
  539. // 提交上传文件
  540. submitFileForm() {
  541. this.$refs.upload.submit();
  542. }
  543. }
  544. };
  545. </script>