plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

725 lines
22 KiB

  1. <script>
  2. import {
  3. selectCollectList,
  4. editCollect,
  5. removeCollect,
  6. saveCollect,
  7. selectCollectListDetail
  8. } from "../../../api/cdc/collect";
  9. import dayjs from "dayjs";
  10. import CollectError from "./collect/collectError.vue";
  11. const tableId = "2000002"
  12. const tableName = "采集数据定义"
  13. const table1 = "2000002Table1"
  14. const table2 = "2000002Table2"
  15. const table3 = "2000002Table3"
  16. export default {
  17. name: "collect",
  18. components: {CollectError},
  19. props:{
  20. height:{
  21. type:Number,
  22. default:700
  23. },
  24. component:{
  25. type:Boolean,
  26. default: false
  27. }
  28. },
  29. data(){
  30. return{
  31. // 异常预警弹出层
  32. errorVisible: false,
  33. // 遮罩层
  34. loading: true,
  35. // 设备信息表格数据
  36. infoList: [],
  37. // 弹出层标题
  38. title: tableName,
  39. // 是否显示弹出层
  40. open: false,
  41. // 查询参数
  42. queryParams: {
  43. collectId: '',
  44. collectDesc: null,
  45. active: "",
  46. },
  47. // 表单参数
  48. form: {},
  49. // 表单校验
  50. rules: {
  51. collectDesc: [
  52. { required: true, message: "数据标识描述不能为空", trigger: "blur" }
  53. ],
  54. collectId: [
  55. { required: true, message: "数据标识ID不能为空", trigger: "blur" }
  56. ],
  57. maxValue: [
  58. { required: true, message: "上限值不能为空", trigger: "blur" }
  59. ],
  60. minValue: [
  61. { required: true, message: "下限值不能为空", trigger: "blur" }
  62. ],
  63. },
  64. deviceColumns:[
  65. {
  66. userId: this.$store.state.user.name,
  67. functionId: tableId,
  68. serialNumber: `${table1}CollectId`,
  69. tableId: table1,
  70. tableName: tableName,
  71. columnProp: 'collectId',
  72. headerAlign: 'center',
  73. align: 'left',
  74. columnLabel: '数据标识ID',
  75. columnHidden: false,
  76. columnImage: false,
  77. columnSortable: false,
  78. sortLv: 0,
  79. status: true,
  80. fixed: '',
  81. columnWidth: 100
  82. },{
  83. userId: this.$store.state.user.name,
  84. functionId: tableId,
  85. serialNumber: `${table1}CollectDesc`,
  86. tableId: table1,
  87. tableName: tableName,
  88. columnProp: 'collectDesc',
  89. headerAlign: 'center',
  90. align: 'left',
  91. columnLabel: '数据标识描述',
  92. columnHidden: false,
  93. columnImage: false,
  94. columnSortable: false,
  95. sortLv: 0,
  96. status: true,
  97. fixed: '',
  98. columnWidth: 120
  99. },{
  100. userId: this.$store.state.user.name,
  101. functionId: tableId,
  102. serialNumber: `${table1}MaxValue`,
  103. tableId: table1,
  104. tableName: tableName,
  105. columnProp: 'maxValue',
  106. headerAlign: 'center',
  107. align: 'right',
  108. columnLabel: '上限值',
  109. columnHidden: false,
  110. columnImage: false,
  111. columnSortable: false,
  112. sortLv: 0,
  113. status: true,
  114. fixed: '',
  115. columnWidth: 100
  116. },{
  117. userId: this.$store.state.user.name,
  118. functionId: tableId,
  119. serialNumber: `${table1}MinValue`,
  120. tableId: table1,
  121. tableName: tableName,
  122. columnProp: 'minValue',
  123. headerAlign: 'center',
  124. align: 'right',
  125. columnLabel: '下限值',
  126. columnHidden: false,
  127. columnImage: false,
  128. columnSortable: false,
  129. sortLv: 0,
  130. status: true,
  131. fixed: '',
  132. columnWidth: 100
  133. },{
  134. userId: this.$store.state.user.name,
  135. functionId: tableId,
  136. serialNumber: `${table1}PhoneInfoFlag`,
  137. tableId: table1,
  138. tableName: tableName,
  139. columnProp: 'phoneInfoFlag',
  140. headerAlign: 'center',
  141. align: 'center',
  142. columnLabel: '短信预警',
  143. columnHidden: false,
  144. columnImage: false,
  145. columnSortable: false,
  146. sortLv: 0,
  147. status: true,
  148. fixed: '',
  149. columnWidth: 100
  150. },{
  151. userId: this.$store.state.user.name,
  152. functionId: tableId,
  153. serialNumber: `${table1}MailInfoFlag`,
  154. tableId: table1,
  155. tableName: tableName,
  156. columnProp: 'mailInfoFlag',
  157. headerAlign: 'center',
  158. align: 'center',
  159. columnLabel: '邮箱预警',
  160. columnHidden: false,
  161. columnImage: false,
  162. columnSortable: false,
  163. sortLv: 0,
  164. status: true,
  165. fixed: '',
  166. columnWidth: 100
  167. },{
  168. userId: this.$store.state.user.name,
  169. functionId: tableId,
  170. serialNumber: `${table1}Remark`,
  171. tableId: table1,
  172. tableName: tableName,
  173. columnProp: 'remark',
  174. headerAlign: 'center',
  175. align: 'left',
  176. columnLabel: '备注',
  177. columnHidden: false,
  178. columnImage: false,
  179. columnSortable: false,
  180. sortLv: 0,
  181. status: true,
  182. fixed: '',
  183. columnWidth: 140
  184. },{
  185. userId: this.$store.state.user.name,
  186. functionId: tableId,
  187. serialNumber: `${table1}Active`,
  188. tableId: table1,
  189. tableName: tableName,
  190. columnProp: 'active',
  191. headerAlign: 'center',
  192. align: 'left',
  193. columnLabel: '在用',
  194. columnHidden: false,
  195. columnImage: false,
  196. columnSortable: false,
  197. sortLv: 0,
  198. status: true,
  199. fixed: '',
  200. columnWidth: 100
  201. },
  202. ],
  203. // 异常预警 header
  204. header:{},
  205. detailList:[],
  206. mailColumns:[
  207. {
  208. userId: this.$store.state.user.name,
  209. functionId: tableId,
  210. serialNumber: `${table2}Username`,
  211. tableId: table2,
  212. tableName: tableName,
  213. columnProp: 'username',
  214. headerAlign: 'center',
  215. align: 'left',
  216. columnLabel: '人员',
  217. columnHidden: false,
  218. columnImage: false,
  219. columnSortable: false,
  220. sortLv: 0,
  221. status: true,
  222. fixed: '',
  223. columnWidth: 100
  224. },{
  225. userId: this.$store.state.user.name,
  226. functionId: tableId,
  227. serialNumber: `${table2}itemValue`,
  228. tableId: table2,
  229. tableName: tableName,
  230. columnProp: 'itemValue',
  231. headerAlign: 'center',
  232. align: 'left',
  233. columnLabel: '邮箱',
  234. columnHidden: false,
  235. columnImage: false,
  236. columnSortable: false,
  237. sortLv: 0,
  238. status: true,
  239. fixed: '',
  240. columnWidth: 100
  241. },{
  242. userId: this.$store.state.user.name,
  243. functionId: tableId,
  244. serialNumber: `${table2}Active`,
  245. tableId: table2,
  246. tableName: tableName,
  247. columnProp: 'active',
  248. headerAlign: 'center',
  249. align: 'left',
  250. columnLabel: '在用',
  251. columnHidden: false,
  252. columnImage: false,
  253. columnSortable: false,
  254. sortLv: 0,
  255. status: true,
  256. fixed: '',
  257. columnWidth: 100
  258. },{
  259. userId: this.$store.state.user.name,
  260. functionId: tableId,
  261. serialNumber: `${table2}CreateBy`,
  262. tableId: table2,
  263. tableName: tableName,
  264. columnProp: 'createBy',
  265. headerAlign: 'center',
  266. align: 'left',
  267. columnLabel: '创建人',
  268. columnHidden: false,
  269. columnImage: false,
  270. columnSortable: false,
  271. sortLv: 0,
  272. status: true,
  273. fixed: '',
  274. columnWidth: 100
  275. },{
  276. userId: this.$store.state.user.name,
  277. functionId: tableId,
  278. serialNumber: `${table2}CreateTime`,
  279. tableId: table2,
  280. tableName: tableName,
  281. columnProp: 'createTime',
  282. headerAlign: 'center',
  283. align: 'center',
  284. columnLabel: '创建时间',
  285. columnHidden: false,
  286. columnImage: false,
  287. columnSortable: false,
  288. sortLv: 0,
  289. status: true,
  290. fixed: '',
  291. columnWidth: 100
  292. },{
  293. userId: this.$store.state.user.name,
  294. functionId: tableId,
  295. serialNumber: `${table2}UpdateBy`,
  296. tableId: table2,
  297. tableName: tableName,
  298. columnProp: 'updateBy',
  299. headerAlign: 'center',
  300. align: 'left',
  301. columnLabel: '修改人',
  302. columnHidden: false,
  303. columnImage: false,
  304. columnSortable: false,
  305. sortLv: 0,
  306. status: true,
  307. fixed: '',
  308. columnWidth: 100
  309. },{
  310. userId: this.$store.state.user.name,
  311. functionId: tableId,
  312. serialNumber: `${table2}UpdateTime`,
  313. tableId: table2,
  314. tableName: tableName,
  315. columnProp: 'updateTime',
  316. headerAlign: 'center',
  317. align: 'center',
  318. columnLabel: '修改时间',
  319. columnHidden: false,
  320. columnImage: false,
  321. columnSortable: false,
  322. sortLv: 0,
  323. status: true,
  324. fixed: '',
  325. columnWidth: 100
  326. },
  327. ],
  328. phoneColumns:[
  329. {
  330. userId: this.$store.state.user.name,
  331. functionId: tableId,
  332. serialNumber: `${table3}Username`,
  333. tableId: table3,
  334. tableName: tableName,
  335. columnProp: 'username',
  336. headerAlign: 'center',
  337. align: 'left',
  338. columnLabel: '人员',
  339. columnHidden: false,
  340. columnImage: false,
  341. columnSortable: false,
  342. sortLv: 0,
  343. status: true,
  344. fixed: '',
  345. columnWidth: 100
  346. },{
  347. userId: this.$store.state.user.name,
  348. functionId: tableId,
  349. serialNumber: `${table3}itemValue`,
  350. tableId: table3,
  351. tableName: tableName,
  352. columnProp: 'itemValue',
  353. headerAlign: 'center',
  354. align: 'left',
  355. columnLabel: '手机号',
  356. columnHidden: false,
  357. columnImage: false,
  358. columnSortable: false,
  359. sortLv: 0,
  360. status: true,
  361. fixed: '',
  362. columnWidth: 100
  363. },{
  364. userId: this.$store.state.user.name,
  365. functionId: tableId,
  366. serialNumber: `${table3}Active`,
  367. tableId: table3,
  368. tableName: tableName,
  369. columnProp: 'active',
  370. headerAlign: 'center',
  371. align: 'left',
  372. columnLabel: '在用',
  373. columnHidden: false,
  374. columnImage: false,
  375. columnSortable: false,
  376. sortLv: 0,
  377. status: true,
  378. fixed: '',
  379. columnWidth: 100
  380. },{
  381. userId: this.$store.state.user.name,
  382. functionId: tableId,
  383. serialNumber: `${table3}CreateBy`,
  384. tableId: table3,
  385. tableName: tableName,
  386. columnProp: 'createBy',
  387. headerAlign: 'center',
  388. align: 'left',
  389. columnLabel: '创建人',
  390. columnHidden: false,
  391. columnImage: false,
  392. columnSortable: false,
  393. sortLv: 0,
  394. status: true,
  395. fixed: '',
  396. columnWidth: 100
  397. },{
  398. userId: this.$store.state.user.name,
  399. functionId: tableId,
  400. serialNumber: `${table3}CreateTime`,
  401. tableId: table3,
  402. tableName: tableName,
  403. columnProp: 'createTime',
  404. headerAlign: 'center',
  405. align: 'center',
  406. columnLabel: '创建时间',
  407. columnHidden: false,
  408. columnImage: false,
  409. columnSortable: false,
  410. sortLv: 0,
  411. status: true,
  412. fixed: '',
  413. columnWidth: 100
  414. },{
  415. userId: this.$store.state.user.name,
  416. functionId: tableId,
  417. serialNumber: `${table3}UpdateBy`,
  418. tableId: table3,
  419. tableName: tableName,
  420. columnProp: 'updateBy',
  421. headerAlign: 'center',
  422. align: 'left',
  423. columnLabel: '修改人',
  424. columnHidden: false,
  425. columnImage: false,
  426. columnSortable: false,
  427. sortLv: 0,
  428. status: true,
  429. fixed: '',
  430. columnWidth: 100
  431. },{
  432. userId: this.$store.state.user.name,
  433. functionId: tableId,
  434. serialNumber: `${table3}UpdateTime`,
  435. tableId: table3,
  436. tableName: tableName,
  437. columnProp: 'updateTime',
  438. headerAlign: 'center',
  439. align: 'center',
  440. columnLabel: '修改时间',
  441. columnHidden: false,
  442. columnImage: false,
  443. columnSortable: false,
  444. sortLv: 0,
  445. status: true,
  446. fixed: '',
  447. columnWidth: 100
  448. },
  449. ],
  450. }
  451. },
  452. methods:{
  453. /** 查询设备信息列表 */
  454. getList() {
  455. let params = {
  456. ...this.queryParams,
  457. site:this.$store.state.user.site
  458. }
  459. this.loading = true;
  460. selectCollectList(params).then(({data}) => {
  461. if (data && data.code === 0){
  462. this.infoList = data.rows;
  463. }
  464. this.loading = false;
  465. }).catch(() => {
  466. this.loading = false;
  467. });
  468. },
  469. // 取消按钮
  470. cancel() {
  471. this.open = false;
  472. this.reset();
  473. },
  474. // 表单重置
  475. reset() {
  476. this.form = {
  477. collectId: '',
  478. site: null,
  479. collectDesc: null,
  480. minValue: null,
  481. maxValue: null,
  482. phoneInfoFlag: 'N',
  483. mailInfoFlag: 'N',
  484. remark: null,
  485. active: 'Y',
  486. createBy: null,
  487. createTime: null
  488. };
  489. this.resetForm("form");
  490. },
  491. /** 搜索按钮操作 */
  492. handleQuery() {
  493. this.getList();
  494. },
  495. /** 新增按钮操作 */
  496. handleAdd() {
  497. this.reset();
  498. this.open = true;
  499. },
  500. /** 修改按钮操作 */
  501. handleUpdate(row) {
  502. this.reset();
  503. this.form = {...row}
  504. this.form.newCollectId = this.form.collectId;
  505. this.open = true;
  506. },
  507. /** 提交按钮 */
  508. submitForm() {
  509. this.$refs["form"].validate((valid,obj) => {
  510. if (valid) {
  511. if (!this.form.newCollectId) {
  512. this.form.site = this.$store.state.user.site;
  513. this.form.createBy = this.$store.state.user.name;
  514. this.form.createTime = dayjs().format("YYYY-MM-DD HH:mm:ss");
  515. saveCollect(this.form).then(({data}) => {
  516. this.form.site = null;
  517. if (data && data.code === 0){
  518. this.$message.success(data.msg);
  519. this.open = false;
  520. this.getList();
  521. }else {
  522. this.$message.warning(data.msg);
  523. }
  524. }).catch((error)=>{
  525. this.$message.error(error);
  526. });
  527. } else {
  528. editCollect(this.form).then(({data}) => {
  529. if (data && data.code === 0){
  530. this.$message.success(data.msg);
  531. this.open = false;
  532. this.getList();
  533. }else {
  534. this.$message.warning(data.msg);
  535. }
  536. }).catch((error)=>{
  537. this.$message.error(error);
  538. });
  539. }
  540. }else {
  541. Object.keys(obj).forEach((key)=>{
  542. this.$message.warning(obj[key][0].message);
  543. return
  544. })
  545. }
  546. });
  547. },
  548. handleDelete(row) {
  549. this.$confirm('此操作将该数据标识, 是否继续?', '提示', {
  550. confirmButtonText: '确定',
  551. cancelButtonText: '取消',
  552. type: 'warning'
  553. }).then(() => {
  554. removeCollect(row).then(({data})=>{
  555. if (data && data.code === 0){
  556. this.$message.success(data.msg);
  557. this.getList();
  558. }else {
  559. this.$message.success(data.msg);
  560. }
  561. }).catch((error)=>{
  562. this.$message.error(error);
  563. })
  564. }).catch(() => {
  565. });
  566. },
  567. handleError(row){
  568. this.header = {...row}
  569. this.getDetailList();
  570. this.errorVisible = true;
  571. },
  572. getDetailList(){
  573. this.detailList = [];
  574. selectCollectListDetail(this.header).then(({data})=>{
  575. if (data && data.code === 0){
  576. this.detailList = data.rows;
  577. }
  578. })
  579. }
  580. },
  581. computed:{
  582. mailList:{
  583. get(){
  584. return this.detailList.filter(item => item.type === 'mail')
  585. }
  586. },
  587. phoneList: {
  588. get() {
  589. return this.detailList.filter(item => item.type === 'phone')
  590. }
  591. }
  592. },
  593. watch:{
  594. "queryParams.collectId"(newVal, oldVal){
  595. this.queryParams.collectId = newVal.toUpperCase();
  596. },
  597. "form.collectId"(newVal, oldVal){
  598. this.form.collectId = newVal.toUpperCase();
  599. },
  600. },
  601. created() {
  602. this.getList();
  603. }
  604. }
  605. </script>
  606. <template>
  607. <div class="app-container">
  608. <el-form :model="queryParams" label-position="top" ref="queryForm" :inline="true" label-width="68px">
  609. <el-form-item label="数据标识ID" prop="collectId">
  610. <el-input
  611. v-model="queryParams.collectId"
  612. placeholder=" "
  613. clearable
  614. />
  615. </el-form-item>
  616. <el-form-item label="数据标识描述" prop="collectDesc">
  617. <el-input
  618. v-model="queryParams.collectDesc"
  619. placeholder=" "
  620. clearable
  621. />
  622. </el-form-item>
  623. <el-form-item label="在用" prop="active">
  624. <el-select v-model="queryParams.active" placeholder="请选择在用" >
  625. <el-option label="全部" value=""/>
  626. <el-option label="在用" value="Y"/>
  627. <el-option label="停用" value="N"/>
  628. </el-select>
  629. </el-form-item>
  630. <el-form-item label=" ">
  631. <el-button type="primary" @click="handleQuery" plain>查询</el-button>
  632. <el-button type="primary" @click="handleAdd" v-if="!component">新增</el-button>
  633. </el-form-item>
  634. </el-form>
  635. <el-table v-loading="loading" border :data="infoList" :height="height">
  636. <el-table-column label="操作" align="center" v-if="!component">
  637. <template slot-scope="scope">
  638. <el-link @click="handleUpdate(scope.row)">编辑</el-link>
  639. <el-link @click="handleDelete(scope.row)">删除</el-link>
  640. <el-link @click="handleError(scope.row)">异常预警</el-link>
  641. </template>
  642. </el-table-column>
  643. <el-table-column
  644. v-for="(item,index) in deviceColumns" :key="index"
  645. :sortable="item.columnSortable"
  646. :prop="item.columnProp"
  647. :header-align="item.headerAlign"
  648. :show-overflow-tooltip="item.showOverflowTooltip"
  649. :align="item.align"
  650. :fixed="item.fixed === ''?false:item.fixed"
  651. :min-width="item.columnWidth"
  652. :label="item.columnLabel">
  653. <template slot-scope="scope">
  654. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  655. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  656. </template>
  657. </el-table-column>
  658. </el-table>
  659. <!-- 添加或修改设备信息对话框 -->
  660. <el-dialog :title="title" v-if="!component" v-drag :visible.sync="open" width="600px" append-to-body>
  661. <el-form ref="form" label-position="top" :model="form" :rules="rules" label-width="80px">
  662. <el-row :gutter="10">
  663. <el-col :span="6">
  664. <el-form-item label="数据标识ID" prop="collectId" :show-message="false">
  665. <el-input v-model="form.collectId" :disabled="form.newCollectId" placeholder=" " />
  666. </el-form-item>
  667. </el-col>
  668. <el-col :span="14">
  669. <el-form-item label="数据标识描述" prop="collectDesc" :show-message="false">
  670. <el-input v-model="form.collectDesc" placeholder=" " />
  671. </el-form-item>
  672. </el-col>
  673. <el-col :span="4">
  674. <el-form-item label=" " prop="phoneInfoFlag" :show-message="false">
  675. <el-checkbox v-model="form.phoneInfoFlag" true-label="Y" false-label="N">短信预警</el-checkbox>
  676. </el-form-item>
  677. </el-col>
  678. <el-col :span="6">
  679. <el-form-item label="上限值" prop="maxValue" :show-message="false">
  680. <el-input-number :controls="false" :step="0" v-model="form.maxValue" placeholder=" " />
  681. </el-form-item>
  682. </el-col>
  683. <el-col :span="6">
  684. <el-form-item label="下限值" prop="minValue" :show-message="false">
  685. <el-input-number :controls="false" :step="0" v-model="form.minValue" placeholder=" " />
  686. </el-form-item>
  687. </el-col>
  688. <el-col :span="6" :offset="2">
  689. <el-form-item label=" " prop="active" :show-message="false">
  690. <el-checkbox v-model="form.active" true-label="Y" false-label="N">在用</el-checkbox>
  691. </el-form-item>
  692. </el-col>
  693. <el-col :span="4">
  694. <el-form-item label=" " prop="mailInfoFlag" :show-message="false">
  695. <el-checkbox v-model="form.mailInfoFlag" true-label="Y" false-label="N">邮箱预警</el-checkbox>
  696. </el-form-item>
  697. </el-col>
  698. <el-col :span="24">
  699. <el-form-item label="备注" prop="remark" :show-message="false">
  700. <el-input v-model="form.remark"></el-input>
  701. </el-form-item>
  702. </el-col>
  703. </el-row>
  704. </el-form>
  705. <div slot="footer" class="dialog-footer">
  706. <el-button type="primary" @click="submitForm"> </el-button>
  707. <el-button @click="cancel"> </el-button>
  708. </div>
  709. </el-dialog>
  710. <collect-error v-if="errorVisible"
  711. :visible.sync="errorVisible"
  712. :collect="header"
  713. :mail-data-list="mailList" :mail-columns="mailColumns"
  714. :phone-data-list="phoneList" :phone-columns="phoneColumns"
  715. @refresh="getDetailList"></collect-error>
  716. </div>
  717. </template>
  718. <style scoped>
  719. </style>