index.vue 17 KB

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