index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  4. <el-form-item label="装置" prop="plantId">
  5. <el-select v-model="queryParams.plantId" @change="handleQuery"
  6. placeholder="请选择装置" clearable size="small">
  7. <el-option
  8. v-for="plant in plantOperation"
  9. :key="plant.plantId"
  10. :label="plant.plantName"
  11. :value="plant.plantId"
  12. />
  13. </el-select>
  14. </el-form-item>
  15. <el-form-item label="设备/管线编号" prop="devCode" label-width="110px">
  16. <el-input
  17. v-model="queryParams.devCode"
  18. placeholder="请输入设备/管线编号"
  19. clearable
  20. @keyup.enter.native="handleQuery"
  21. />
  22. </el-form-item>
  23. <el-form-item label="设备/管线描述" prop="devDescribe" label-width="110px">
  24. <el-input
  25. v-model="queryParams.devDescribe"
  26. placeholder="请输入设备/管线描述"
  27. clearable
  28. @keyup.enter.native="handleQuery"
  29. />
  30. </el-form-item>
  31. <el-form-item>
  32. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  33. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  34. </el-form-item>
  35. </el-form>
  36. <el-row :gutter="10" class="mb8">
  37. <el-col :span="1.5">
  38. <el-button
  39. type="primary"
  40. plain
  41. icon="el-icon-plus"
  42. size="mini"
  43. @click="handleAdd"
  44. v-hasPermi="['base:device:add']"
  45. >新增
  46. </el-button>
  47. </el-col>
  48. <el-col :span="1.5">
  49. <el-button
  50. type="success"
  51. plain
  52. icon="el-icon-edit"
  53. size="mini"
  54. :disabled="single"
  55. @click="handleUpdate"
  56. v-hasPermi="['base:device:edit']"
  57. >修改
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="danger"
  63. plain
  64. icon="el-icon-delete"
  65. size="mini"
  66. :disabled="multiple"
  67. @click="handleDelete"
  68. v-hasPermi="['base:device:remove']"
  69. >删除
  70. </el-button>
  71. </el-col>
  72. <el-col :span="1.5">
  73. <el-button
  74. type="warning"
  75. plain
  76. icon="el-icon-upload2"
  77. size="mini"
  78. @click="handleImport"
  79. v-hasPermi="['base:device:add']"
  80. >导入
  81. </el-button>
  82. </el-col>
  83. <el-col :span="1.5">
  84. <el-button
  85. type="warning"
  86. plain
  87. icon="el-icon-download"
  88. size="mini"
  89. @click="handleExport"
  90. v-hasPermi="['base:device:export']"
  91. >导出
  92. </el-button>
  93. </el-col>
  94. <el-col :span="1.5">
  95. <el-button
  96. type="info"
  97. plain
  98. icon="el-icon-position"
  99. size="mini"
  100. :disabled="multiple"
  101. @click="handleToApprove"
  102. >送审
  103. </el-button>
  104. </el-col>
  105. <el-col :span="1.5">
  106. <el-button
  107. type="info"
  108. plain
  109. icon="el-icon-s-check"
  110. size="mini"
  111. :disabled="multiple"
  112. @click="handleApprove"
  113. v-hasPermi="['base:device:approve']"
  114. >审核
  115. </el-button>
  116. </el-col>
  117. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  118. </el-row>
  119. <el-table v-loading="loading" :data="deviceList" :cell-style="tableCellStyle"
  120. @selection-change="handleSelectionChange" :height="clientHeight" border>
  121. <el-table-column type="selection" width="55" align="center" fixed="left"/>
  122. <el-table-column label="审核状态" align="center" fixed="left" prop="approveStatus"
  123. :formatter="approveStatusFormat" :show-overflow-tooltip="true" width="80"/>
  124. <el-table-column label="装置名称" align="center" prop="plantName" :show-overflow-tooltip="true" width="180"/>
  125. <el-table-column label="装置编编码" align="center" prop="plantCode" :show-overflow-tooltip="true" width="100"/>
  126. <el-table-column label="区域名称" align="center" prop="regionName" :show-overflow-tooltip="true" width="150"/>
  127. <el-table-column label="区域编号" align="center" prop="regionCode" :show-overflow-tooltip="true" width="100"/>
  128. <el-table-column label="设备/管线编号" align="center" prop="devCode" :show-overflow-tooltip="true" width="130"/>
  129. <el-table-column label="设备/管线描述" align="center" prop="devDescribe" :show-overflow-tooltip="true"
  130. width="230"/>
  131. <el-table-column label="主要物料/产品" align="center" prop="material" :show-overflow-tooltip="true" width="130"/>
  132. <el-table-column label="物料状态" align="center" prop="materialStatus" :show-overflow-tooltip="true" width="100"/>
  133. <el-table-column label="合成相应因子" align="center" prop="responseFactor" :show-overflow-tooltip="true"
  134. width="100"/>
  135. <el-table-column label="相应因子来源" align="center" prop="responseFactorFrom" :show-overflow-tooltip="true"
  136. width="100"/>
  137. <el-table-column label="维护人" align="center" prop="updater" :show-overflow-tooltip="true" width="100"/>
  138. <el-table-column label="维护时间" align="center" prop="updatedate" width="180">
  139. <template slot-scope="scope">
  140. <span>{{ parseTime(scope.row.updatedate, '{y}-{m}-{d}') }}</span>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="备注" align="center" prop="remark" :show-overflow-tooltip="true" width="230"/>
  144. <el-table-column label="操作" align="center" fixed="right" class-name="small-padding fixed-width" width="120">
  145. <template slot-scope="scope">
  146. <el-button
  147. size="mini"
  148. type="text"
  149. icon="el-icon-edit"
  150. @click="handleUpdate(scope.row)"
  151. v-hasPermi="['base:device:edit']"
  152. v-if="scope.row.approveStatus==0"
  153. >修改
  154. </el-button>
  155. <el-button
  156. size="mini"
  157. type="text"
  158. icon="el-icon-delete"
  159. @click="handleDelete(scope.row)"
  160. v-hasPermi="['base:device:remove']"
  161. v-if="scope.row.approveStatus==0"
  162. >删除
  163. </el-button>
  164. <el-button
  165. size="mini"
  166. type="text"
  167. icon="el-icon-circle-close"
  168. @click="handleDisabled(scope.row.devId)"
  169. v-hasPermi="['base:device:remove']"
  170. v-if="scope.row.approveStatus==2"
  171. >作废
  172. </el-button>
  173. </template>
  174. </el-table-column>
  175. </el-table>
  176. <pagination
  177. v-show="total>0"
  178. :total="total"
  179. :page.sync="queryParams.pageNum"
  180. :limit.sync="queryParams.pageSize"
  181. @pagination="getList"
  182. />
  183. <!-- 添加或修改设备/管线对话框 -->
  184. <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
  185. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  186. <el-form-item label="装置" prop="plantId">
  187. <el-select v-model="form.plantId" placeholder="请选择装置" clearable size="small" style="width: 100%"
  188. @change="getAllRegion(form.plantId)">
  189. <el-option
  190. v-for="dict in plantOperation"
  191. :key="dict.plantId"
  192. :label="dict.plantName"
  193. :value="dict.plantId"
  194. />
  195. </el-select>
  196. </el-form-item>
  197. <el-form-item label="区域" prop="regionId">
  198. <el-select v-model="form.regionId" placeholder="请选择区域" clearable size="small" style="width: 100%">
  199. <el-option
  200. v-for="dict in regionOperation"
  201. :key="dict.regionId"
  202. :label="dict.regionName"
  203. :value="dict.regionId"
  204. />
  205. </el-select>
  206. </el-form-item>
  207. <el-form-item label="设备/管线编号" prop="devCode">
  208. <el-input v-model="form.devCode" placeholder="请输入设备/管线编号"/>
  209. </el-form-item>
  210. <el-form-item label="设备/管线描述" prop="devDescribe">
  211. <el-input v-model="form.devDescribe" placeholder="请输入设备/管线描述"/>
  212. </el-form-item>
  213. <el-form-item label="主要物料/产品" prop="material">
  214. <el-input v-model="form.material" placeholder="请输入主要物料/产品"/>
  215. </el-form-item>
  216. <el-form-item label="物料状态" prop="materialStatus">
  217. <el-input v-model="form.materialStatus" placeholder="请输入物料状态"/>
  218. </el-form-item>
  219. <el-form-item label="合成相应因子" prop="responseFactor">
  220. <el-input v-model="form.responseFactor" placeholder="请输入合成相应因子"/>
  221. </el-form-item>
  222. <el-form-item label="相应因子来源" prop="responseFactorFrom">
  223. <el-input v-model="form.responseFactorFrom" placeholder="请输入相应因子来源"/>
  224. </el-form-item>
  225. <el-form-item label="备注" prop="remark">
  226. <el-input v-model="form.remark" placeholder="请输入备注"/>
  227. </el-form-item>
  228. </el-form>
  229. <div slot="footer" class="dialog-footer">
  230. <el-button type="primary" @click="submitForm">确 定</el-button>
  231. <el-button @click="cancel">取 消</el-button>
  232. </div>
  233. </el-dialog>
  234. <!-- 用户导入对话框 -->
  235. <el-dialog v-dialogDrag :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
  236. <el-upload
  237. ref="upload"
  238. :limit="1"
  239. accept=".xlsx, .xls"
  240. :headers="upload.headers"
  241. :action="upload.url"
  242. :disabled="upload.isUploading"
  243. :on-progress="handleFileUploadProgress"
  244. :on-success="handleFileSuccess"
  245. :auto-upload="false"
  246. drag
  247. >
  248. <i class="el-icon-upload"></i>
  249. <div class="el-upload__text">
  250. {{ $t('将文件拖到此处,或') }}
  251. <em>{{ $t('点击上传') }}</em>
  252. </div>
  253. <div class="el-upload__tip" slot="tip">
  254. <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
  255. <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
  256. </div>
  257. <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
  258. <input name="type" :value="upload.type" hidden/>
  259. </form>
  260. <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
  261. </el-upload>
  262. <div slot="footer" class="dialog-footer">
  263. <el-button type="primary" @click="submitFileForm" v-loading.fullscreen.lock="fullscreenLoading">{{
  264. $t('确 定')
  265. }}
  266. </el-button>
  267. <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
  268. </div>
  269. </el-dialog>
  270. </div>
  271. </template>
  272. <script>
  273. import {addDevice, delDevice, getDevice, handleApprove, listDevice, updateDevice, handleDisabled} from "@/api/base/device";
  274. import {getAllPlantName} from "@/api/base/plant";
  275. import {getAllRegion} from "@/api/base/region";
  276. import {MessageBox} from 'element-ui'
  277. import {getToken} from "@/utils/auth";
  278. export default {
  279. name: "Device",
  280. data() {
  281. return {
  282. plantOperation: [],
  283. regionOperation: [],
  284. approveStatusOperation: [],
  285. clientHeight: 300,
  286. // 遮罩层
  287. loading: true,
  288. // 选中数组l
  289. ids: [],
  290. status: [],
  291. // 非单个禁用
  292. single: true,
  293. // 非多个禁用
  294. multiple: true,
  295. // 显示搜索条件
  296. showSearch: false,
  297. // 总条数
  298. total: 0,
  299. // 设备/管线表格数据
  300. deviceList: [],
  301. // 弹出层标题
  302. title: "",
  303. // 是否显示弹出层
  304. open: false,
  305. fullscreenLoading: false,
  306. // 用户导入参数
  307. upload: {
  308. downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
  309. //下载模板类型
  310. type: "baseDevice",
  311. // 是否显示弹出层(用户导入)
  312. open: false,
  313. // 弹出层标题(用户导入)
  314. title: "",
  315. // 是否禁用上传
  316. isUploading: false,
  317. // 是否更新已经存在的用户数据
  318. updateSupport: 0,
  319. // 设置上传的请求头部
  320. headers: {Authorization: "Bearer " + getToken()},
  321. // 上传的地址
  322. url: process.env.VUE_APP_BASE_API + "/base/device/importData"
  323. },
  324. // 查询参数
  325. queryParams: {
  326. pageNum: 1,
  327. pageSize: 10,
  328. plantId: null,
  329. regionId: null,
  330. devCode: null,
  331. devDescribe: null,
  332. approveStatus: null,
  333. approveTime: null,
  334. deptId: null,
  335. createrCode: null,
  336. createdate: null,
  337. updaterCode: null,
  338. updatedate: null,
  339. responseFactorFrom: null,
  340. responseFactor: null,
  341. materialStatus: null,
  342. material: null
  343. },
  344. // 表单参数
  345. form: {},
  346. // 表单校验
  347. rules: {
  348. regionId: [
  349. {required: true, message: this.$t('区域') + this.$t('不能为空'), trigger: "blur"}
  350. ],
  351. plantId: [
  352. {required: true, message: this.$t('装置') + this.$t('不能为空'), trigger: "blur"}
  353. ],
  354. devDescribe: [
  355. {required: true, message: this.$t('描述') + this.$t('不能为空'), trigger: "blur"}
  356. ],
  357. devCode: [
  358. {required: true, message: this.$t('编号') + this.$t('不能为空'), trigger: "blur"}
  359. ],
  360. }
  361. };
  362. },
  363. created() {
  364. this.getList();
  365. //设置表格高度对应屏幕高度
  366. this.$nextTick(() => {
  367. this.clientHeight = (document.body.clientHeight - 80) * 0.8
  368. });
  369. getAllPlantName().then(response => {
  370. this.plantOperation = response.data;
  371. })
  372. this.getDicts("base_approve_status").then(response => {
  373. this.approveStatusOperation = response.data;
  374. });
  375. },
  376. methods: {
  377. // 提交上传文件
  378. submitFileForm() {
  379. this.$refs.upload.submit();
  380. this.fullscreenLoading = true;
  381. },
  382. /** 导入按钮操作 */
  383. handleImport() {
  384. this.upload.title = this.$t('用户导入');
  385. this.upload.open = true;
  386. },
  387. /** 下载模板操作 */
  388. importTemplate() {
  389. this.$refs['downloadFileForm'].submit()
  390. },
  391. // 文件上传中处理
  392. handleFileUploadProgress(event, file, fileList) {
  393. this.upload.isUploading = true;
  394. },
  395. // 文件上传成功处理
  396. handleFileSuccess(response, file, fileList) {
  397. this.upload.open = false;
  398. this.upload.isUploading = false;
  399. this.$refs.upload.clearFiles();
  400. this.fullscreenLoading = false;
  401. console.log(response)
  402. if (response.data === 0) {
  403. this.$alert(this.$t('导入失败!') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
  404. } else if (response.data[0] != null) {
  405. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
  406. } else {
  407. this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
  408. }
  409. this.getList();
  410. },
  411. approveStatusFormat(row, column) {
  412. return this.selectDictLabel(this.approveStatusOperation, row.approveStatus);
  413. },
  414. tableCellStyle({row, column, rowIndex, columnIndex}) {
  415. if (columnIndex === 1 && row.approveStatus == 2) {
  416. return "color:#13C2C2;";
  417. }
  418. if (columnIndex === 1 && row.approveStatus == 1) {
  419. return "color:#0000FF;";
  420. }
  421. if (columnIndex === 1 && row.approveStatus == 0) {
  422. return "color:#ff0000;";
  423. }
  424. },
  425. getAllRegion(val) {
  426. this.form.regionId = '';
  427. if (val != null && val != '') {
  428. getAllRegion(val).then(response => {
  429. this.regionOperation = response.data;
  430. }
  431. )
  432. } else {
  433. this.regionOperation = [];
  434. }
  435. },
  436. /** 查询设备/管线列表 */
  437. getList() {
  438. this.loading = true;
  439. listDevice(this.queryParams).then(response => {
  440. this.deviceList = response.rows;
  441. this.total = response.total;
  442. this.loading = false;
  443. });
  444. },
  445. // 取消按钮
  446. cancel() {
  447. this.open = false;
  448. this.reset();
  449. },
  450. // 表单重置
  451. reset() {
  452. this.form = {
  453. devId: null,
  454. plantId: null,
  455. regionId: null,
  456. devCode: null,
  457. devDescribe: null,
  458. remark: null,
  459. approveStatus: 0,
  460. approveTime: null,
  461. deptId: null,
  462. delFlag: null,
  463. createrCode: null,
  464. createdate: null,
  465. updaterCode: null,
  466. updatedate: null,
  467. responseFactorFrom: null,
  468. responseFactor: null,
  469. materialStatus: null,
  470. material: null
  471. };
  472. this.resetForm("form");
  473. this.regionOperation = [];
  474. },
  475. /** 搜索按钮操作 */
  476. handleQuery() {
  477. this.queryParams.pageNum = 1;
  478. this.getList();
  479. },
  480. /** 重置按钮操作 */
  481. resetQuery() {
  482. this.resetForm("queryForm");
  483. this.handleQuery();
  484. },
  485. // 多选框选中数据
  486. handleSelectionChange(selection) {
  487. this.ids = selection.map(item => item.devId)
  488. this.status = selection.map(item => item.approveStatus)
  489. this.single = selection.length !== 1
  490. this.multiple = !selection.length
  491. },
  492. /** 新增按钮操作 */
  493. handleAdd() {
  494. this.reset();
  495. this.open = true;
  496. this.title = "添加设备/管线";
  497. },
  498. /** 修改按钮操作 */
  499. handleUpdate(row) {
  500. this.reset();
  501. const devId = row.devId || this.ids
  502. getDevice(devId).then(response => {
  503. this.form = response.data;
  504. if (this.form.approveStatus != 0) {
  505. MessageBox.alert('已送审/已审核的数据不可修改!', '注意!', {
  506. confirmButtonText: '确定',
  507. })
  508. return;
  509. }
  510. getAllRegion(this.form.plantId).then(response => {
  511. this.regionOperation = response.data;
  512. console.log(this.regionOperation)
  513. }
  514. )
  515. this.open = true;
  516. this.title = "修改设备/管线";
  517. });
  518. },
  519. /** 提交按钮 */
  520. submitForm() {
  521. this.$refs["form"].validate(valid => {
  522. if (valid) {
  523. if (this.form.devId != null) {
  524. updateDevice(this.form).then(response => {
  525. this.$modal.msgSuccess("修改成功");
  526. this.open = false;
  527. this.getList();
  528. });
  529. } else {
  530. addDevice(this.form).then(response => {
  531. this.$modal.msgSuccess("新增成功");
  532. this.open = false;
  533. this.getList();
  534. });
  535. }
  536. }
  537. });
  538. },
  539. handleDisabled(id){
  540. this.$modal.confirm('是否确认作废数据项?注意!该操作不可逆!作废后该设备下的所有密封点都将一并作废!').then(function () {
  541. return handleDisabled(id);
  542. }).then(() => {
  543. this.getList();
  544. this.$modal.msgSuccess("作废成功");
  545. }).catch(() => {
  546. });
  547. },
  548. /** 删除按钮操作 */
  549. handleDelete(row) {
  550. const ids = row.devId || this.ids;
  551. if (row.approveStatus === undefined) {
  552. for (let i = 0; i < this.status.length; i++) {
  553. if (this.status[i] != 0) {
  554. MessageBox.alert('已送审/已审核的数据不可删除!', '注意!', {
  555. confirmButtonText: '确定',
  556. })
  557. return
  558. }
  559. }
  560. } else if (row.approveStatus != 0) {
  561. MessageBox.alert('已送审/已审核的数据不可删除!', '注意!', {
  562. confirmButtonText: '确定',
  563. })
  564. return
  565. }
  566. this.$modal.confirm('是否确认删除数据项?').then(function () {
  567. return delDevice(ids);
  568. }).then(() => {
  569. this.getList();
  570. this.$modal.msgSuccess("删除成功");
  571. }).catch(() => {
  572. });
  573. },
  574. /** 导出按钮操作 */
  575. handleExport() {
  576. this.download('base/device/export', {
  577. ...this.queryParams
  578. }, `受控设备台账_${new Date().getTime()}.xlsx`)
  579. },
  580. handleToApprove() {
  581. let data = {};
  582. data.devIds = this.ids;
  583. data.approveStatus = 1;
  584. handleApprove(data).then(() => {
  585. this.getList();
  586. })
  587. },
  588. handleApprove() {
  589. let data = {};
  590. data.devIds = this.ids;
  591. data.approveStatus = 2;
  592. handleApprove(data).then(() => {
  593. this.getList();
  594. })
  595. }
  596. }
  597. };
  598. </script>