index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455
  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="管线号" prop="pipelineNo">
  5. <el-input
  6. v-model="queryParams.pipelineNo"
  7. placeholder="请输入管线号"
  8. clearable
  9. size="small"
  10. @keyup.enter.native="handleQuery"
  11. />
  12. </el-form-item>
  13. <el-form-item label="P&ID图号" prop="pidNo">
  14. <el-input
  15. v-model="queryParams.pidNo"
  16. placeholder="请输入P&ID图号"
  17. clearable
  18. size="small"
  19. @keyup.enter.native="handleQuery"
  20. />
  21. </el-form-item>
  22. <el-form-item>
  23. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  24. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-row :gutter="10" class="mb8">
  28. <el-col :span="1.5">
  29. <el-button
  30. type="primary"
  31. icon="el-icon-plus"
  32. size="mini"
  33. @click="handleAdd"
  34. v-hasPermi="['pssr:overhaulPipe:add']"
  35. >新增
  36. </el-button>
  37. </el-col>
  38. <el-col :span="1.5">
  39. <el-button
  40. type="success"
  41. icon="el-icon-edit"
  42. size="mini"
  43. :disabled="single"
  44. @click="handleUpdate"
  45. v-hasPermi="['pssr:overhaulPipe:edit']"
  46. >修改
  47. </el-button>
  48. </el-col>
  49. <el-col :span="1.5">
  50. <el-button
  51. type="danger"
  52. icon="el-icon-delete"
  53. size="mini"
  54. :disabled="multiple"
  55. @click="handleDelete"
  56. v-hasPermi="['pssr:overhaulPipe:remove']"
  57. >删除
  58. </el-button>
  59. </el-col>
  60. <el-col :span="1.5">
  61. <el-button
  62. type="info"
  63. icon="el-icon-upload2"
  64. size="mini"
  65. @click="handleImport"
  66. v-hasPermi="['pssr:overhaulPipe:edit']"
  67. >导入
  68. </el-button>
  69. </el-col>
  70. <el-col :span="1.5">
  71. <el-button
  72. type="warning"
  73. icon="el-icon-download"
  74. size="mini"
  75. @click="handleExport"
  76. v-hasPermi="['pssr:overhaulPipe:export']"
  77. >导出
  78. </el-button>
  79. </el-col>
  80. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  81. </el-row>
  82. <el-table v-loading="loading" :data="overhaulPipeList" @selection-change="handleSelectionChange"
  83. :height="clientHeight" border>
  84. <el-table-column type="selection" width="55" align="center"/>
  85. <el-table-column label="管线号" align="center" prop="pipelineNo" :show-overflow-tooltip="true"/>
  86. <el-table-column label="更换原因" align="center" prop="changeReason" :show-overflow-tooltip="true"/>
  87. <el-table-column label="P&ID图号" align="center" prop="pidNo" :show-overflow-tooltip="true"/>
  88. <el-table-column label="确认人" align="center" prop="confirmer" :show-overflow-tooltip="true"/>
  89. <el-table-column label="完成时间" align="center" prop="confirmationDate" width="100">
  90. <template slot-scope="scope">
  91. <span>{{ parseTime(scope.row.confirmationDate, '{y}-{m}-{d}') }}</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
  95. <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
  96. <template slot-scope="scope">
  97. <el-button
  98. size="mini"
  99. type="text"
  100. icon="el-icon-edit"
  101. @click="handleUpdate(scope.row)"
  102. v-hasPermi="['pssr:overhaulPipe:edit']"
  103. >修改
  104. </el-button>
  105. <el-button
  106. size="mini"
  107. type="text"
  108. icon="el-icon-delete"
  109. @click="handleDelete(scope.row)"
  110. v-hasPermi="['pssr:overhaulPipe:remove']"
  111. >删除
  112. </el-button>
  113. </template>
  114. </el-table-column>
  115. </el-table>
  116. <pagination
  117. v-show="total>0"
  118. :total="total"
  119. :page.sync="queryParams.pageNum"
  120. :limit.sync="queryParams.pageSize"
  121. @pagination="getList"
  122. />
  123. <!-- 添加或修改检修项目-管线对话框 -->
  124. <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
  125. <el-form ref="form" :model="form" :rules="rules" label-width="80px">
  126. <el-form-item label="管线号" prop="pipelineNo">
  127. <el-input v-model="form.pipelineNo" placeholder="请输入管线号"/>
  128. </el-form-item>
  129. <el-form-item label="更换原因" prop="changeReason">
  130. <el-input v-model="form.changeReason" placeholder="请输入更换原因"/>
  131. </el-form-item>
  132. <el-form-item label="P&ID图号" prop="pidNo">
  133. <el-input v-model="form.pidNo" placeholder="请输入P&ID图号"/>
  134. </el-form-item>
  135. <el-form-item label="确认人" prop="confirmer">
  136. <el-input v-model="form.confirmer" placeholder="请输入确认人"/>
  137. </el-form-item>
  138. <el-form-item label="完成时间" prop="confirmationDate">
  139. <el-date-picker clearable size="small" style="width: 200px"
  140. v-model="form.confirmationDate"
  141. type="date"
  142. value-format="yyyy-MM-dd"
  143. placeholder="选择完成时间">
  144. </el-date-picker>
  145. </el-form-item>
  146. <el-form-item label="备注" prop="remarks">
  147. <el-input v-model="form.remarks" placeholder="请输入备注"/>
  148. </el-form-item>
  149. </el-form>
  150. <div slot="footer" class="dialog-footer">
  151. <el-button type="primary" @click="submitForm">确 定</el-button>
  152. <el-button @click="cancel">取 消</el-button>
  153. </div>
  154. </el-dialog>
  155. <!-- 用户导入对话框 -->
  156. <el-dialog :close-on-click-modal="false" :title="upload.title" :visible.sync="upload.open" width="400px"
  157. append-to-body>
  158. <el-upload
  159. ref="upload"
  160. :limit="1"
  161. accept=".xlsx, .xls"
  162. :headers="upload.headers"
  163. :action="upload.url + '?updateSupport=' + upload.updateSupport"
  164. :disabled="upload.isUploading"
  165. :on-progress="handleFileUploadProgress"
  166. :on-success="handleFileSuccess"
  167. :auto-upload="false"
  168. drag
  169. >
  170. <i class="el-icon-upload"></i>
  171. <div class="el-upload__text">
  172. 将文件拖到此处,或
  173. <em>点击上传</em>
  174. </div>
  175. <div class="el-upload__tip" slot="tip">
  176. <el-checkbox v-model="upload.updateSupport"/>
  177. 是否更新已经存在的用户数据
  178. <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
  179. </div>
  180. <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
  181. </el-upload>
  182. <div slot="footer" class="dialog-footer">
  183. <el-button type="primary" @click="submitFileForm">确 定</el-button>
  184. <el-button @click="upload.open = false">取 消</el-button>
  185. </div>
  186. </el-dialog>
  187. </div>
  188. </template>
  189. <script>
  190. import {
  191. addOverhaulPipe,
  192. delOverhaulPipe,
  193. exportOverhaulPipe,
  194. getOverhaulPipe,
  195. importTemplate,
  196. listOverhaulPipe,
  197. updateOverhaulPipe
  198. } from "@/api/pssr/overhaulPipe";
  199. import {treeselect} from "@/api/system/dept";
  200. import {getToken} from "@/utils/auth";
  201. import Treeselect from "@riophae/vue-treeselect";
  202. import "@riophae/vue-treeselect/dist/vue-treeselect.css";
  203. import {groupList} from "@/api/pssr/region";
  204. import {listUserNoPage} from "@/api/system/user";
  205. export default {
  206. name: "OverhaulPipe",
  207. components: {Treeselect},
  208. props: {
  209. subId: {
  210. type: Number,
  211. default: 0
  212. }
  213. },
  214. data() {
  215. return {
  216. regionGroupOptions: [],
  217. unitOptions: [],
  218. userOptions: [],
  219. // 遮罩层
  220. loading: true,
  221. // 选中数组
  222. ids: [],
  223. // 非单个禁用
  224. single: true,
  225. // 非多个禁用
  226. multiple: true,
  227. // 显示搜索条件
  228. showSearch: false,
  229. // 总条数
  230. total: 0,
  231. // 检修项目-管线表格数据
  232. overhaulPipeList: [],
  233. // 弹出层标题
  234. title: "",
  235. // 部门树选项
  236. deptOptions: undefined,
  237. clientHeight: 300,
  238. // 是否显示弹出层
  239. open: false,
  240. // 用户导入参数
  241. upload: {
  242. // 是否显示弹出层(用户导入)
  243. open: false,
  244. // 弹出层标题(用户导入)
  245. title: "",
  246. // 是否禁用上传
  247. isUploading: false,
  248. // 是否更新已经存在的用户数据
  249. updateSupport: 0,
  250. // 设置上传的请求头部
  251. headers: {Authorization: "Bearer " + getToken()},
  252. // 上传的地址
  253. url: process.env.VUE_APP_BASE_API + "/pssr/overhaulPipe/importData"
  254. },
  255. // 查询参数
  256. queryParams: {
  257. pageNum: 1,
  258. pageSize: 20,
  259. subId: this.subId,
  260. approveId: null,
  261. pipelineNo: null,
  262. changeReason: null,
  263. pidNo: null,
  264. confirmer: null,
  265. confirmationDate: null,
  266. createrCode: null,
  267. createdate: null,
  268. updaterCode: null,
  269. updatedate: null,
  270. deptId: null,
  271. remarks: null
  272. },
  273. // 表单参数
  274. form: {},
  275. // 表单校验
  276. rules: {}
  277. };
  278. },
  279. watch: {
  280. // 根据名称筛选部门树
  281. deptName(val) {
  282. this.$refs.tree.filter(val);
  283. }
  284. },
  285. created() {
  286. //设置表格高度对应屏幕高度
  287. this.$nextTick(() => {
  288. this.clientHeight = document.body.clientHeight - 250
  289. })
  290. this.getList();
  291. this.getTreeselect();
  292. listUserNoPage({}).then(res => {
  293. this.userOptions = res.data
  294. });
  295. groupList({}).then(res => {
  296. this.regionGroupOptions = res.data;
  297. });
  298. },
  299. methods: {
  300. /** 查询检修项目-管线列表 */
  301. getList() {
  302. this.loading = true;
  303. listOverhaulPipe(this.queryParams).then(response => {
  304. this.overhaulPipeList = response.rows;
  305. this.total = response.total;
  306. this.loading = false;
  307. });
  308. },
  309. /** 查询部门下拉树结构 */
  310. getTreeselect() {
  311. treeselect().then(response => {
  312. this.deptOptions = response.data;
  313. });
  314. },
  315. // 取消按钮
  316. cancel() {
  317. this.open = false;
  318. this.reset();
  319. },
  320. // 表单重置
  321. reset() {
  322. this.form = {
  323. id: null,
  324. subId: this.subId,
  325. approveId: null,
  326. pipelineNo: null,
  327. changeReason: null,
  328. pidNo: null,
  329. confirmer: null,
  330. confirmationDate: null,
  331. delFlag: null,
  332. createrCode: null,
  333. createdate: null,
  334. updaterCode: null,
  335. updatedate: null,
  336. deptId: null,
  337. remarks: null
  338. };
  339. this.resetForm("form");
  340. },
  341. /** 搜索按钮操作 */
  342. handleQuery() {
  343. this.queryParams.pageNum = 1;
  344. this.getList();
  345. },
  346. /** 重置按钮操作 */
  347. resetQuery() {
  348. this.resetForm("queryForm");
  349. this.handleQuery();
  350. },
  351. // 多选框选中数据
  352. handleSelectionChange(selection) {
  353. this.ids = selection.map(item => item.id)
  354. this.single = selection.length !== 1
  355. this.multiple = !selection.length
  356. },
  357. /** 新增按钮操作 */
  358. handleAdd() {
  359. this.reset();
  360. this.open = true;
  361. this.title = "添加检修项目-管线";
  362. },
  363. /** 修改按钮操作 */
  364. handleUpdate(row) {
  365. this.reset();
  366. const id = row.id || this.ids
  367. getOverhaulPipe(id).then(response => {
  368. this.form = response.data;
  369. this.open = true;
  370. this.title = "修改检修项目-管线";
  371. });
  372. },
  373. /** 提交按钮 */
  374. submitForm() {
  375. this.$refs["form"].validate(valid => {
  376. if (valid) {
  377. if (this.form.id != null) {
  378. updateOverhaulPipe(this.form).then(response => {
  379. this.msgSuccess("修改成功");
  380. this.open = false;
  381. this.getList();
  382. });
  383. } else {
  384. addOverhaulPipe(this.form).then(response => {
  385. this.msgSuccess("新增成功");
  386. this.open = false;
  387. this.getList();
  388. });
  389. }
  390. }
  391. });
  392. },
  393. /** 删除按钮操作 */
  394. handleDelete(row) {
  395. const ids = row.id || this.ids;
  396. this.$confirm('是否确认删除?', "警告", {
  397. confirmButtonText: "确定",
  398. cancelButtonText: "取消",
  399. type: "warning"
  400. }).then(function () {
  401. return delOverhaulPipe(ids);
  402. }).then(() => {
  403. this.getList();
  404. this.msgSuccess("删除成功");
  405. })
  406. },
  407. /** 导出按钮操作 */
  408. handleExport() {
  409. const queryParams = this.queryParams;
  410. this.$confirm('是否确认导出所有检修项目-管线数据项?', "警告", {
  411. confirmButtonText: "确定",
  412. cancelButtonText: "取消",
  413. type: "warning"
  414. }).then(function () {
  415. return exportOverhaulPipe(queryParams);
  416. }).then(response => {
  417. this.download(response.msg);
  418. })
  419. },
  420. /** 导入按钮操作 */
  421. handleImport() {
  422. this.upload.title = "用户导入";
  423. this.upload.open = true;
  424. },
  425. /** 下载模板操作 */
  426. importTemplate() {
  427. importTemplate().then(response => {
  428. this.download(response.msg);
  429. });
  430. },
  431. // 文件上传中处理
  432. handleFileUploadProgress(event, file, fileList) {
  433. this.upload.isUploading = true;
  434. },
  435. // 文件上传成功处理
  436. handleFileSuccess(response, file, fileList) {
  437. this.upload.open = false;
  438. this.upload.isUploading = false;
  439. this.$refs.upload.clearFiles();
  440. this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
  441. this.getList();
  442. },
  443. // 提交上传文件
  444. submitFileForm() {
  445. this.$refs.upload.submit();
  446. }
  447. }
  448. };
  449. </script>