index.vue 18 KB

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