index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container" style="padding-bottom: 0px">
  4. <div class="search-box-area" id="searchBox">
  5. <div class="search-item">
  6. <el-cascader
  7. class="filter-item form-search-input fl"
  8. v-model="queryParam.department_id"
  9. placeholder="请选择所属部门"
  10. :options="departments"
  11. clearable
  12. :props="{
  13. checkStrictly: true,
  14. label: 'department_name',
  15. value: 'id',
  16. }"
  17. @change="handleChange"
  18. ></el-cascader>
  19. </div>
  20. <div class="search-item">
  21. <el-input
  22. v-model="queryParam.number"
  23. placeholder="请输入设备编号"
  24. clearable
  25. class="filter-item form-search-input fl"
  26. @keyup.enter.native="handleSearch"
  27. />
  28. </div>
  29. <div class="search-item">
  30. <el-input
  31. v-model="queryParam.name"
  32. placeholder="请输入设备名称"
  33. clearable
  34. class="filter-item form-search-input fl"
  35. @keyup.enter.native="handleSearch"
  36. />
  37. </div>
  38. <div class="search-item">
  39. <el-select
  40. v-model="queryParam.model"
  41. placeholder="请输入设备型号"
  42. class="filter-item form-search-input fl"
  43. clearable
  44. >
  45. <el-option
  46. v-for="item in deviceTypes"
  47. :key="item.value"
  48. :label="item.text"
  49. :value="item.value">
  50. </el-option>
  51. </el-select>
  52. </div>
  53. <div class="search-item">
  54. <el-select
  55. v-model="queryParam.is_used"
  56. placeholder="启用状态"
  57. class="filter-item form-search-input fl"
  58. clearable
  59. >
  60. <el-option value="0" label="未使用">启用</el-option>
  61. <el-option value="1" label="已使用">停用</el-option>
  62. </el-select>
  63. </div>
  64. </div>
  65. <div class="search-operate-area">
  66. <!-- <el-input v-model="queryParam.code" placeholder="唯一编码" clearable class="filter-item form-search-input fl" /> -->
  67. <el-button
  68. class="filter-item search fl"
  69. icon="el-icon-search"
  70. @click="handleSearch"
  71. >搜索</el-button
  72. >
  73. <el-button
  74. class="filter-item fl"
  75. icon="el-icon-refresh"
  76. @click="handleRefresh"
  77. >重置</el-button
  78. >
  79. <el-button
  80. class="filter-item search fl"
  81. :icon="this.searchDisplay ? 'el-icon-arrow-up' : 'el-icon-arrow-down'"
  82. @click="searchDis"
  83. >{{ word }}</el-button
  84. >
  85. </div>
  86. <div class="list-operate-area">
  87. <!-- <el-button size="mini" class="filter-item search fl" icon="el-icon-plus" @click="handleCreate">添加</el-button> -->
  88. <el-button
  89. class="filter-item search fl"
  90. icon="el-icon-setting"
  91. @click="showColumnOption"
  92. >列设置</el-button
  93. >
  94. <el-button
  95. class="filter-item search fl"
  96. icon="el-icon-refresh-right"
  97. @click="refresh"
  98. >刷新</el-button
  99. >
  100. </div>
  101. </div>
  102. <el-table
  103. :data="data"
  104. v-loading="loading"
  105. ref="multipleTable"
  106. @selection-change="hydraulicSelectMulti"
  107. @sort-change="sortChange"
  108. :dynamicColumnSetting="true"
  109. tooltip-effect="dark"
  110. style="width: 100%"
  111. border
  112. fit
  113. >
  114. <el-table-column
  115. type="selection"
  116. fixed="left"
  117. width="55"
  118. ></el-table-column>
  119. <el-table-column
  120. prop="material_number"
  121. label="物料号"
  122. align="center"
  123. v-if="showColumn.material_number"
  124. width="120"
  125. />
  126. <!-- <el-table-column
  127. prop="net_state"
  128. label="在线状态"
  129. align="center"
  130. v-if="showColumn.net_state"
  131. :show-overflow-tooltip="true"
  132. width="80"
  133. >
  134. <template slot-scope="record">
  135. <el-tag type="success" v-if="record.row.net_state == '0'" >在线</el-tag >
  136. <el-tag type="gray" v-else-if="record.row.net_state == '1'" >离线</el-tag >
  137. <el-tag type="danger" v-else>从未上线</el-tag>
  138. </template>
  139. </el-table-column> -->
  140. <el-table-column
  141. prop="classification"
  142. label="设备分类"
  143. align="center"
  144. v-if="showColumn.classification"
  145. />
  146. <el-table-column
  147. prop="equ_type_name"
  148. label="设备类别"
  149. align="center"
  150. v-if="showColumn.equ_type_name"
  151. width="120"
  152. />
  153. <el-table-column
  154. prop="name"
  155. label="设备名称"
  156. align="center"
  157. v-if="showColumn.name"
  158. width="120"
  159. />
  160. <el-table-column
  161. prop="equipment_model"
  162. label="设备型号"
  163. align="center"
  164. v-if="showColumn.equipment_model"
  165. />
  166. <el-table-column
  167. prop="issue_unit"
  168. label="发放单位"
  169. align="center"
  170. v-if="showColumn.issue_unit"
  171. />
  172. <el-table-column
  173. prop="fixed_asset_number"
  174. label="固定资产编号"
  175. align="center"
  176. v-if="showColumn.fixed_asset_number"
  177. />
  178. <el-table-column
  179. prop="fixed_asset_number2"
  180. label="类固资产编号"
  181. align="center"
  182. v-if="showColumn.fixed_asset_number"
  183. />
  184. <el-table-column
  185. prop="serial_number"
  186. label="序列号"
  187. align="center"
  188. v-if="showColumn.serial_number"
  189. />
  190. <el-table-column
  191. prop="factory_number"
  192. label="出厂编号"
  193. align="center"
  194. v-if="showColumn.factory_number"
  195. />
  196. <el-table-column
  197. prop="check_last_time"
  198. label="上次校验时间"
  199. align="center"
  200. v-if="showColumn.check_last_time"
  201. width="100"
  202. />
  203. <el-table-column
  204. prop="check_next_time"
  205. label="下次校验时间"
  206. align="center"
  207. width="100"
  208. v-if="showColumn.check_next_time"
  209. />
  210. <el-table-column
  211. prop="check_status1"
  212. label="校验状态"
  213. align="center"
  214. v-if="showColumn.check_status1"
  215. />
  216. <el-table-column
  217. prop="status1"
  218. label="状态"
  219. align="center"
  220. v-if="showColumn.status1"
  221. />
  222. <!-- <el-table-column
  223. prop="status"
  224. label="状态"
  225. align="center"
  226. v-if="showColumn.status"
  227. :show-overflow-tooltip="true"
  228. >
  229. <template slot-scope="record">
  230. <el-switch
  231. v-model="record.row.is_used"
  232. active-color="#13ce66"
  233. @change="changeUsedEvent(record.row,$event)"
  234. inactive-color="#ff4949">
  235. </el-switch>
  236. </template>
  237. </el-table-column> -->
  238. <!-- <el-table-column
  239. prop="online_time"
  240. label="在线时间"
  241. align="center"
  242. v-if="showColumn.online_time"
  243. width="130"
  244. />
  245. <el-table-column
  246. prop="check_time"
  247. label="校准日期"
  248. align="center"
  249. v-if="showColumn.check_time"
  250. width="130"
  251. />
  252. <el-table-column
  253. prop="effective_period"
  254. label="有效周期"
  255. align="center"
  256. v-if="showColumn.effective_period"
  257. width="100"
  258. />
  259. <el-table-column
  260. prop="effective_time"
  261. label="有效截止时间"
  262. align="center"
  263. v-if="showColumn.effective_time"
  264. width="130"
  265. />
  266. <el-table-column
  267. prop="creator_user"
  268. label="导入用户"
  269. align="center"
  270. v-if="showColumn.creator_user"
  271. :show-overflow-tooltip="true"
  272. />
  273. <el-table-column
  274. prop="created_at"
  275. label="添加时间"
  276. align="center"
  277. v-if="showColumn.created_at"
  278. :show-overflow-tooltip="true"
  279. width="130"
  280. />
  281. <el-table-column
  282. prop="remark"
  283. label="显示信息"
  284. align="center"
  285. v-if="showColumn.remark"
  286. :show-overflow-tooltip="true"
  287. /> -->
  288. <el-table-column
  289. label="操作"
  290. width="180"
  291. align="center"
  292. fixed="right"
  293. >
  294. <template slot-scope="record">
  295. <el-tooltip
  296. content="修改"
  297. placement="top"
  298. :enterable="false"
  299. >
  300. <el-button
  301. type="primary"
  302. size="mini"
  303. icon="el-icon-edit"
  304. @click="handleUpdate(record.row)"
  305. ></el-button>
  306. </el-tooltip>
  307. <el-tooltip
  308. content="查看"
  309. placement="top"
  310. :enterable="false"
  311. >
  312. <el-button
  313. type="primary"
  314. size="mini"
  315. icon="el-icon-view"
  316. @click="handleDetail(record.row)"
  317. ></el-button>
  318. </el-tooltip>
  319. <el-button type="danger" size="mini" icon="el-icon-delete" @click="handleDelete(record.row.id)" />
  320. </template>
  321. </el-table-column>
  322. </el-table>
  323. <transition name="fade">
  324. <div class="columnOption" v-show="isShowColumn">
  325. <div class="content">
  326. <div class="head">选择显示字段</div>
  327. <div class="body">
  328. <el-checkbox v-model="checkList.depart_name" disabled>所属部门</el-checkbox>
  329. <!-- <el-checkbox v-model="checkList.alarm_state_text" disabled>告警状态</el-checkbox> -->
  330. <el-checkbox v-model="checkList.material_number">物料号</el-checkbox>
  331. <el-checkbox v-model="checkList.classification">设备分类</el-checkbox>
  332. <el-checkbox v-model="checkList.equ_type_name">设备类别</el-checkbox>
  333. <el-checkbox v-model="checkList.name">名称</el-checkbox>
  334. <el-checkbox v-model="checkList.equipment_model">设备型号</el-checkbox>
  335. <el-checkbox v-model="checkList.fixed_asset_number">固定资产编号</el-checkbox>
  336. <el-checkbox v-model="checkList.fixed_asset_number2">类固定资产编号</el-checkbox>
  337. <el-checkbox v-model="checkList.serial_number">序列号</el-checkbox>
  338. <el-checkbox v-model="checkList.factory_number">出厂编号</el-checkbox>
  339. <el-checkbox v-model="checkList.check_last_time">上次校验时间</el-checkbox>
  340. <el-checkbox v-model="checkList.check_next_time">下次校验时间</el-checkbox>
  341. <el-checkbox v-model="checkList.check_status1">校验状态</el-checkbox>
  342. <el-checkbox v-model="checkList.status1">状态</el-checkbox>
  343. </div>
  344. <div class="footer">
  345. <el-button size="small" type="primary" plain @click="saveColumn"
  346. >保存列配置</el-button
  347. >
  348. </div>
  349. </div>
  350. </div>
  351. </transition>
  352. <el-button
  353. type="primary"
  354. icon="el-icon-plus"
  355. :loading="downloadLoading"
  356. style="margin-top: 15px"
  357. @click="handleCreate"
  358. >添加</el-button
  359. >
  360. <el-button
  361. type="danger"
  362. icon="el-icon-delete"
  363. v-if="selectedIds.length > 0"
  364. style="margin-top: 15px"
  365. @click="handleMultiDelete()"
  366. >删除</el-button
  367. >
  368. <el-button
  369. type="warning"
  370. icon="el-icon-download"
  371. :loading="downloadLoading"
  372. style="margin-top: 15px"
  373. @click="exportExcel"
  374. >导出</el-button
  375. >
  376. <el-button
  377. type="success"
  378. icon="el-icon-upload"
  379. :loading="downloadLoading"
  380. style="margin-top: 15px"
  381. @click="importExcel"
  382. >导入</el-button
  383. >
  384. <el-pagination
  385. background
  386. class="pagination-container"
  387. @size-change="handleSizeChange"
  388. @current-change="handleCurrentChange"
  389. :current-page="paginate.current"
  390. :page-sizes="paginate.sizes"
  391. :page-size="paginate.limit"
  392. :layout="paginate.layout"
  393. :total="paginate.total"
  394. />
  395. <keep-alive>
  396. <form-model
  397. @sendVal="closeDialog"
  398. :formModelVisible="formVisible"
  399. :title="title"
  400. :ref="formName"
  401. />
  402. </keep-alive>
  403. <detail
  404. :detailVisible="detailVisible"
  405. @sendVal="closeDrawer"
  406. :record="detail"
  407. />
  408. <hydraulicDetail
  409. :detailVisible="hydraulicDetailVisible"
  410. @sendVal="closeDrawer"
  411. :record="hydraulicDetail"
  412. />
  413. <wrenchDetail
  414. :detailVisible="wrenchDetailVisible"
  415. @sendVal="closeDrawer"
  416. :record="wrenchDetail"
  417. />
  418. <!-- 导入弹框 -->
  419. <el-dialog
  420. title="导入液压设备"
  421. append-to-body
  422. width="400px"
  423. :visible.sync="uploadDialogVisible"
  424. custom-class="upload-dialog"
  425. >
  426. <el-cascader
  427. v-model="selectedDepartId"
  428. class="filter-item form-search-input fl"
  429. :options="departments"
  430. :props="{ checkStrictly: true, label: 'department_name', value: 'id' }"
  431. style="margin-bottom: 10px"
  432. @change="changeCards"
  433. ></el-cascader>
  434. <el-upload
  435. class="upload-demo"
  436. drag
  437. :action="actionUrl"
  438. :headers="headers"
  439. :before-upload="beforeUpload"
  440. :show-file-list="true"
  441. :on-change="onchange"
  442. :on-remove="onremove"
  443. :on-exceed="onexeced"
  444. :limit="1"
  445. ref="upload"
  446. >
  447. <i class="el-icon-upload"></i>
  448. <div class="el-upload__text">
  449. 将文件拖到此处,或
  450. <em>点击上传</em>
  451. </div>
  452. <div class="el-upload__tip upload-tips" slot="tip">
  453. 只能上传xls/xlsx文件
  454. </div>
  455. </el-upload>
  456. <el-link
  457. type="primary"
  458. href="https://rlfd.oss-cn-hangzhou.aliyuncs.com/smart_tool/import_pump.xls"
  459. style="margin-top: 10px"
  460. >下载模板</el-link
  461. >
  462. <span slot="footer" class="dialog-footer">
  463. <el-button @click="uploadDialogVisible = false">取 消</el-button>
  464. <el-button type="primary" @click="importCards" :loading="loadings">{{
  465. submitText
  466. }}</el-button>
  467. </span>
  468. </el-dialog>
  469. </div>
  470. </template>
  471. <script>
  472. import rlListOperate from "@/layout/rl-list-operate/rlListOperate";
  473. import { action } from "@/directive/permission/index.js";
  474. import { getToken } from "../../../utils/auth";
  475. import detail from "./detail.vue"
  476. import wrenchDetail from "./wrench_detail.vue"
  477. import hydraulicDetail from "./hydraulic_detail.vue"
  478. import formModel from './formModel.vue'
  479. export default {
  480. name: "hydraulic",
  481. directives: { action },
  482. mixins: [rlListOperate],
  483. components: {
  484. formModel,
  485. detail,
  486. wrenchDetail,
  487. hydraulicDetail
  488. },
  489. data() {
  490. return {
  491. url: "hydEquipment",
  492. queryParam: {
  493. number: "",
  494. department_id: [],
  495. name: "",
  496. model: "",
  497. is_used: "",
  498. },
  499. deviceTypes:[],
  500. current_type: {
  501. 0: "success",
  502. 1: "danger",
  503. },
  504. formName:'hydraulic',
  505. formVisible:false,
  506. //搜索
  507. searchDisplay: true,
  508. departments: [],
  509. //详情
  510. detailVisible:false,
  511. detail:{},
  512. //泵详情
  513. hydraulicDetailVisible:false,
  514. hydraulicDetail:{},
  515. //扳手详情
  516. wrenchDetailVisible:false,
  517. wrenchDetail:{},
  518. isShowColumn: false,
  519. // 列的配置化对象,存储配置信息
  520. checkList: {},
  521. showColumn: {
  522. material_number: true,
  523. classification: true,
  524. equ_type_name:true,
  525. name:true,
  526. equipment_model: true,
  527. issue_unit: true,
  528. fixed_asset_number:true,
  529. fixed_asset_number2: true,
  530. serial_number: true,
  531. factory_number:true,
  532. check_last_time:true,
  533. check_next_time:true,
  534. check_status1:true,
  535. status1: true,
  536. },
  537. //导入请求url
  538. actionUrl: process.env.VUE_APP_BASE_API + "/upload/file_excel",
  539. headers: { authorization: "Bearer " + getToken() },
  540. excel_url: "", //上传学生Excel返回的url
  541. uploadDialogVisible: false, //下发配置显示与否
  542. selectedDepartId: "",
  543. loadings: false,
  544. submitText: "确 定",
  545. };
  546. },
  547. created() {
  548. this.$http.get("departments").then((response) => {
  549. this.departments = response.data;
  550. });
  551. // 0-液压泵
  552. this.$http.get("get_device_mold",{ params: {type:0} }).then(resp => {
  553. this.deviceTypes = resp.data
  554. });
  555. },
  556. methods: {
  557. handleChange(val) {
  558. // console.log(val)
  559. this.queryParam.department_id = val;
  560. this.handleSearch();
  561. },
  562. hydraulicSelectMulti(data) {
  563. this.selectedIds = [];
  564. data.forEach((item) => {
  565. this.selectedIds.push(item.id);
  566. });
  567. },
  568. refresh() {
  569. this.queryParam.page = this.paginate.current;
  570. this.getList();
  571. },
  572. searchDis() {
  573. this.searchDisplay = !this.searchDisplay;
  574. var searchBoxHeght = document.getElementById("searchBox");
  575. if (this.searchDisplay == false) {
  576. searchBoxHeght.style.height = 40 + "px";
  577. } else {
  578. searchBoxHeght.style.height = "auto";
  579. }
  580. },
  581. showColumnOption() {
  582. this.isShowColumn = true;
  583. },
  584. saveColumn() {
  585. localStorage.setItem("hydEquSet", JSON.stringify(this.checkList));
  586. this.isShowColumn = false;
  587. },
  588. handleDetail(row){
  589. if(row.equipment_type==2)
  590. {
  591. this.hydraulicDetailVisible=true;
  592. this.hydraulicDetail=row;
  593. }
  594. if(row.equipment_type==2||row.equipment_type==3)
  595. {
  596. this.wrenchDetailVisible=true;
  597. this.wrenchDetail=row;
  598. }
  599. else
  600. {
  601. this.detailVisible = true,
  602. this.detail = row
  603. }
  604. },
  605. closeDrawer(){
  606. this.detailVisible = false;
  607. this.hydraulicDetailVisible=false;
  608. this.wrenchDetailVisible=false;
  609. },
  610. changeUsedEvent(row,value){
  611. this.$http.put('hydraulic/' + row.id, { is_used: value }).then(resp => {
  612. if (resp.code === 10000) {
  613. this.$message.success('操作成功')
  614. // row[field] = val
  615. // this.$emit('rowClick', row)
  616. }
  617. })
  618. },
  619. importExcel() {
  620. this.uploadDialogVisible = true;
  621. },
  622. changeCards(v) {
  623. this.selectedDepartId = v[v.length - 1];
  624. },
  625. beforeUpload(file) {
  626. if (!/\.(xlsx|xls|XLSX|XLS)$/.test(file.name)) {
  627. this.$notify.error({
  628. title: "错误",
  629. message: "上传文件只能为excel文件,且为xlsx,xls格式",
  630. });
  631. return false;
  632. }
  633. return true;
  634. },
  635. onremove() {
  636. //移除文件钩子
  637. this.excel_url = "";
  638. },
  639. onexeced(files) {
  640. if (files.length == 1) {
  641. this.$message.error("只能上传一个文件");
  642. }
  643. },
  644. onchange(file, fileList) {
  645. if (file.response) {
  646. this.$message.success(file.response.data.msg);
  647. this.excel_url = file.response.data.excel_url;
  648. } else {
  649. // console.log(file);
  650. }
  651. },
  652. importCards() {
  653. // console.log(this.excel_url);
  654. var url = this.excel_url,
  655. depart_id = this.selectedDepartId;
  656. if (depart_id == "") {
  657. this.$message.error("请选择部门");
  658. return;
  659. }
  660. if (url == "") {
  661. this.$message.error("请上传文件");
  662. return;
  663. }
  664. this.loadings = true;
  665. this.submitText = "导入中";
  666. this.$http
  667. .post("cardDevice/import", { url: url, depart_id: depart_id })
  668. .then((response) => {
  669. if (response.data.error) {
  670. this.$message.error(response.data.msg);
  671. } else {
  672. this.$message.success(response.data);
  673. }
  674. this.excel_url = "";
  675. this.selectedDepartId = "";
  676. this.$refs.upload.clearFiles();
  677. this.loadings = false;
  678. this.submitText = "确定";
  679. this.uploadDialogVisible = false;
  680. this.getList();
  681. });
  682. },
  683. },
  684. watch: {
  685. // 监听复选框配置列所有的变化
  686. checkList: {
  687. handler: function (newnew, oldold) {
  688. // console.log(newnew);
  689. this.showColumn = newnew;
  690. // 这里需要让表格重新绘制一下,否则会产生固定列错位的情况
  691. this.$nextTick(() => {
  692. this.$refs.multipleTable.doLayout();
  693. });
  694. },
  695. deep: true,
  696. immediate: true,
  697. },
  698. },
  699. computed: {
  700. word: function () {
  701. if (this.searchDisplay == false) {
  702. //对文字进行处理
  703. return "展开";
  704. } else {
  705. return "收起";
  706. }
  707. },
  708. },
  709. mounted() {
  710. // this.getIsUseVoice();
  711. this.$nextTick(function () {
  712. this.searchDis();
  713. });
  714. // 发请求得到checkListInitData的列的名字
  715. if (localStorage.getItem("hydEquSet")) {
  716. this.checkList = JSON.parse(localStorage.getItem("hydEquSet"));
  717. } else {
  718. this.checkList = {
  719. material_number: true,
  720. classification: true,
  721. equ_type_name:true,
  722. name:true,
  723. equipment_model: true,
  724. issue_unit: true,
  725. fixed_asset_number:true,
  726. fixed_asset_number2: true,
  727. serial_number: true,
  728. factory_number:true,
  729. check_last_time:true,
  730. check_next_time:true,
  731. check_status1:true,
  732. status1: true,
  733. };
  734. }
  735. },
  736. };
  737. </script>
  738. <style lang="scss" scoped>
  739. @import "@/views/device/hydraulic/index.scss";
  740. </style>