From 4ae49d50244c67d5e2bda208019be4944870c695 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 25 八月 2022 19:06:01 +0800
Subject: [PATCH] 1.点检部位增删查改实现
---
src/views/sbgl/djbz.vue | 743 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 740 insertions(+), 3 deletions(-)
diff --git a/src/views/sbgl/djbz.vue b/src/views/sbgl/djbz.vue
index b334a97..c858a88 100644
--- a/src/views/sbgl/djbz.vue
+++ b/src/views/sbgl/djbz.vue
@@ -1,11 +1,748 @@
-<template />
+<template>
+ <div>
+ <div class="body" :style="{height:mainHeight+'px'}">
+ <div class="bodyTopButtonGroup">
+ <el-button type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
+ <el-button icon="el-icon-download" @click="upload">瀵煎叆</el-button>
+ </div>
+
+ <div class="bodyTopFormGroup">
+ <el-form
+ ref="form"
+ :model="form"
+ label-width="80px"
+ inline
+ style="display: flex;justify-content: space-between"
+ >
+ <div class="elForm">
+ <el-form-item label="鏍囧噯缂栫爜" style=" display: flex;">
+ <el-input v-model="form.checkstandcode" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鏍囧噯鍚嶇О" style=" display: flex;">
+ <el-input v-model="form.checkstandname" placeholder="璇疯緭鍏�" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鐐规绠℃帶" style=" display: flex;">
+ <el-select v-model="form.checkcontr" style="width: 200px" placeholder="璇烽�夋嫨">
+ <el-option
+ v-for="item in checkcontrArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </el-form-item>
+ </div>
+ <div style="display: flex;align-items: start;margin-top: 5px;z-index: 2">
+ <el-button type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>
+ <el-button type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
+ </div>
+ </el-form>
+ </div>
+
+ <div class="elTableDiv">
+ <el-table
+ :data="tableData"
+ :height="tableHeight+'px'"
+ border
+ :row-class-name="tableRowClassName"
+ :style="{width: 100+'%',height:tableHeight+'px',}"
+ highlight-current-row
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ @sort-change="sortChange"
+ >
+ <!-- <el-table-column-->
+ <!-- type="selection"-->
+ <!-- width="50"-->
+ <!-- />-->
+ <el-table-column
+ prop="RowNum"
+ width="50"
+ label="搴忓彿"
+ />
+ <el-table-column
+ prop="org_code"
+ label="鏍囧噯缂栫爜"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="org_name"
+ label="鏍囧噯鍚嶇О"
+ sortable="custom"
+ />
+
+ <el-table-column
+ prop="parentorg_name"
+ label="鏍囧噯鎻忚堪"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="parentorg_name"
+ label="鐐规绠℃帶"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="parentorg_name"
+ label="鍏宠仈璁惧"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="lm_user"
+ label="鍒涘缓浜哄憳"
+ sortable="custom"
+ />
+ <el-table-column
+ prop="lm_date"
+ label="鍒涘缓鏃堕棿"
+ width="160"
+ sortable="custom"
+ />
+ <el-table-column
+ label="鎿嶄綔"
+ >
+ <template slot-scope="{row}">
+ <div class="operationClass">
+ <el-button type="text" @click="edit('edit',row)">缂栬緫</el-button>
+ <el-button type="text" @click="del(row)">鍒犻櫎</el-button>
+ </div>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ <!--鍒嗛〉-->
+ <pagination
+ :total="total"
+ :page.sync="form.page"
+ :limit.sync="form.rows"
+ align="right"
+ layout="prev, pager, next,sizes"
+ popper-class="select_bottom"
+ @pagination="getDeviceCheckStandArdSearch"
+ />
+ </div>
+
+ <el-dialog
+ :title="operation==='add'?'鏂板':'缂栬緫'"
+ :visible.sync="dialogVisible"
+ width="800px"
+ :close-on-click-modal="false"
+ top="8vh"
+ @closed="handleClose"
+ @close="handleClose"
+ >
+ <div>
+ <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />璁惧鐐规鏍囧噯淇℃伅
+ </div>
+ <div style="margin: 0 30px;">
+ <el-form ref="dialogForm" inline :rules="dialogFormRules" :model="dialogForm" label-width="80px">
+ <el-form-item label="鏍囧噯缂栫爜" prop="code">
+ <el-input v-model="dialogForm.code" :disabled="operation!=='add'" style="width: 200px" />
+ </el-form-item>
+ <el-form-item label="鏍囧噯鍚嶇О" prop="name">
+ <el-input v-model="dialogForm.name" style="width: 200px" />
+ </el-form-item>
+ <el-form-item prop="SupUnit" label="鐐规绠℃帶">
+ <el-select
+ v-model="dialogForm.enable"
+ style="width: 200px"
+ placeholder="璇烽�夋嫨"
+ :popper-append-to-body="false"
+ >
+ <el-option
+ v-for="item in checkcontrArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鏍囧噯鎻忚堪" prop="description">
+ <el-input v-model="dialogForm.description" type="textarea" style="width: 200px" />
+ </el-form-item>
+ </el-form>
+ </div>
+ <div>
+ <i class="el-icon-s-operation" style="color:#42b983;margin: -20px 10px 20px 0" />璁惧鐐规鐐规淇℃伅
+ </div>
+ <div style="margin-bottom:10px">
+ <el-button type="primary" icon="el-icon-circle-plus-outline" @click="addRow">鏂板</el-button>
+ </div>
+ <div class="elTableDiv">
+ <el-table
+ :data="tableDataDialog"
+ :height="(tableHeight-300)+'px'"
+ border
+ :row-class-name="tableRowClassName"
+ :style="{width: 100+'%',height:(tableHeight-300)+'px',}"
+ highlight-current-row
+ :header-cell-style="this.$headerCellStyle"
+ :cell-style="this.$cellStyle"
+ >
+ <el-table-column
+ type="index"
+ width="50"
+ label="搴忓彿"
+ />
+ <el-table-column
+ prop="checkitem_code"
+ label="鐐规閮ㄤ綅缂栫爜"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.isVisible===0">{{ row.checkitem_code }}</div>
+ <el-select
+ v-if="row.isVisible===1"
+ v-model="row.checkitem_code"
+ placeholder="璇烽�夋嫨"
+ @change="val=>selectChange(val,row)"
+ >
+ <el-option
+ v-for="item in checkItemSelectArr"
+ :key="item.name"
+ :label="item.code"
+ :value="item.name"
+ />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="checkitem_name"
+ label="鐐规閮ㄤ綅鍚嶇О"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.isVisible===0">{{ row.checkitem_name }}</div>
+ <el-select
+ v-if="row.isVisible===1"
+ v-model="row.checkitem_code"
+ placeholder="璇烽�夋嫨"
+ @change="val=>selectChange(val,row)"
+ >
+ <el-option
+ v-for="item in checkItemSelectArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </template>
+ </el-table-column>
+
+ <el-table-column
+ prop="chkdesc"
+ label="鐐规瑕佹眰"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.isVisible===0">{{ row.chkdesc }}</div>
+ <el-input v-else v-model="row.chkdesc" />
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="isscan"
+ label="閫夋嫨鎵爜"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.isVisible===0">{{ row.isscan==='Y'?'鏄�':'鍚�' }}</div>
+ <el-select
+ v-if="row.isVisible===1"
+ v-model="row.isscan"
+ placeholder="璇烽�夋嫨"
+ >
+ <el-option
+ v-for="item in checkcontrArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column
+ prop="cycle"
+ label="鐐规鍛ㄦ湡"
+ >
+ <template slot-scope="{row}">
+ <div v-if="row.isVisible===0">{{ row.cycle==='D'?'鏃�':'' }}</div>
+ <el-select
+ v-if="row.isVisible===1"
+ v-model="row.cycle"
+ placeholder="璇烽�夋嫨"
+ >
+ <el-option
+ v-for="item in cycleArr"
+ :key="item.code"
+ :label="item.name"
+ :value="item.code"
+ />
+ </el-select>
+ </template>
+ </el-table-column>
+ <el-table-column
+ label="鎿嶄綔"
+ width="120"
+ fixed="right"
+ >
+ <template slot-scope="{row}">
+ <div class="operationClass">
+ <el-button v-if="row.isVisible===0" type="text" @click="editRow(row)">缂栬緫</el-button>
+ <el-button v-if="row.isVisible===0" type="text" @click="delRow(row)">鍒犻櫎</el-button>
+
+ <el-button v-if="row.isVisible===1" type="text" @click="saveRow(row)">纭</el-button>
+ <el-button v-if="row.isVisible===1" type="text" @click="cancelRow(row)">鍙栨秷</el-button>
+ </div>
+ </template>
+ </el-table-column>
+ </el-table>
+ </div>
+ <span slot="footer" class="dialog-footer">
+ <div class="footerButton">
+ <el-button @click="dialogVisibleCancel">鍙� 娑�</el-button>
+ <el-button type="primary" @click="dialogVisibleConfirm">纭� 瀹�</el-button>
+ </div>
+ </span>
+ </el-dialog>
+
+ <!--瀵煎叆缁勪欢-->
+ <import-picker
+ ref="importPickerFunc"
+ class="importPickerClass"
+ :shows.sync="shows"
+ :title="title_value"
+ :colos="colos"
+ :code="code"
+ />
+
+ </div>
+</template>
<script>
+import Pagination from '@/components/Pagination'
+import { AddUpdateOrganization, DeleteOrganization, OrganizationSearch, PrentOrganization } from '@/api/jcsz'
+import { getCookie } from '@/utils/auth'
+import ImportPicker from '@/components/ImportPicker'
+import { AddUpdateDeviceCheckStandArd, DeviceCheckItemSelect, DeviceCheckStandArdSearch } from '@/api/sbgl'
+
+const SER_HZ = /^[\u4e00-\u9fa5]+$/
export default {
- name: 'Djbz'
+ name: 'Zzjg',
+ components: {
+ Pagination, ImportPicker
+ },
+ data() {
+ const validateName = (rule, value, callback) => {
+ if (!value) {
+ return callback(new Error('璇疯緭鍏ョ紪鐮�'))
+ } else {
+ if (SER_HZ.test(value)) {
+ return callback(new Error('缂栫爜涓嶈兘涓轰腑鏂�'))
+ } else {
+ callback()
+ }
+ }
+ }
+ const validateTypeCode = (rule, value, callback) => {
+ if (!value) {
+ return callback(new Error('璇烽�夋嫨涓婄骇'))
+ } else {
+ callback()
+ }
+ }
+ return {
+ mainHeight: 0,
+ tableHeight: 0,
+ form: {
+ checkstandcode: '', // 鏍囧噯缂栫爜
+ checkstandname: '', // 鏍囧噯鍚嶇О
+ checkcontr: '', // 鐐规绠℃帶
+ prop: 'lm_date', // 鎺掑簭瀛楁
+ order: 'desc', // 鎺掑簭瀛楁
+ page: 1, // 绗嚑椤�
+ rows: 20 // 姣忛〉澶氬皯鏉�
+ },
+ checkcontrArr: [
+ { code: 'Y', name: '鏄�' },
+ { code: 'N', name: '鍚�' }
+ ],
+ cycleArr: [
+ { code: 'D', name: '鏃�' }
+ ],
+ total: 10,
+ tableData: [],
+ dialogVisible: false,
+ dialogForm: {
+ code: '',
+ name: '',
+ enable: 'Y',
+ description: ''// 涓婄骇鍗曚綅
+ },
+ operation: '',
+ dialogFormRules: {
+
+ code: [
+ { required: true, validator: validateName, trigger: ['blur', 'change'] }
+ ],
+ name: [
+ { required: true, message: '璇疯緭鍏ユ爣鍑嗗悕绉�', trigger: ['blur', 'change'] }
+ ],
+ enable: [
+ { required: true, message: '', trigger: ['blur', 'change'] }
+ ]
+ },
+ tableDataDialog: [], // 琛ㄦ牸鏁版嵁
+ tableDataDialogSelected: [], // 宸查�塩ode
+ checkItemSelectArr: [],
+
+ title_value: '鏁版嵁瀵煎叆 / 鐐规閮ㄤ綅',
+ code: '4',
+ shows: false
+
+ }
+ },
+ watch: {
+ shows() {
+ if (!this.shows) {
+ this.getDeviceCheckStandArdSearch()
+ }
+ }
+ },
+ created() {
+ this.getDeviceCheckStandArdSearch()
+ },
+ mounted() {
+ window.addEventListener('resize', this.getHeight)
+ this.getHeight()
+ },
+ methods: {
+ async getDeviceCheckStandArdSearch() {
+ console.log(this.form, 11)
+ const res = await DeviceCheckStandArdSearch(this.form)
+ this.tableData = res.data
+ this.total = res.count
+ },
+ // 鎺掑簭鏀瑰彉鏃�
+ sortChange({ column, prop, order }) {
+ if (order === 'descending') {
+ order = 'desc'
+ } else if (order === 'ascending') {
+ order = 'asc'
+ } else {
+ order = 'desc'
+ }
+ this.form.order = order
+ this.form.prop = prop
+ this.getDeviceCheckStandArdSearch()
+ },
+ // 鏌ヨ
+ search() {
+ this.getDeviceCheckStandArdSearch()
+ },
+ // 瀵煎叆鎸夐挳
+ upload() {
+ this.shows = true
+ this.$refs.importPickerFunc.newDataFunc()
+ },
+ colos() {
+ this.shows = false
+ },
+ // 閲嶇疆
+ reset() {
+ this.form.OrgCode = ''
+ this.form.OrgName = ''
+ this.form.OrgType = ''
+ this.form.UserName = ''
+ this.getDeviceCheckStandArdSearch()
+ },
+
+ async getDeviceCheckItemSelect() {
+ const { data: res } = await DeviceCheckItemSelect()
+ this.checkItemSelectArr = res
+ },
+
+ // 鏂板鎸夐挳
+ add(operation) {
+ this.operation = operation
+ this.dialogVisible = true
+ this.getDeviceCheckItemSelect()
+ },
+ // 淇敼鎸夐挳
+ edit(operation, row) {
+ this.operation = operation
+ this.dialogVisible = true
+ this.getDeviceCheckItemSelect()
+
+ this.$nextTick(() => {
+ this.dialogForm.OrgCode = row.org_code
+ this.dialogForm.OrgName = row.org_name
+ this.dialogForm.SupUnit = row.parent_id
+ })
+ },
+ // 鍒犻櫎鎸夐挳
+ async del(row) {
+ this.$confirm('鏄惁纭鍒犻櫎?', '鎻愮ず', {
+ confirmButtonText: '纭畾',
+ cancelButtonText: '鍙栨秷',
+ type: 'warning'
+ }).then(() => {
+ DeleteOrganization({ orgid: row.code }).then(res => {
+ if (res.code === '200') {
+ this.$message.success('鍒犻櫎鎴愬姛!')
+ this.getDeviceCheckStandArdSearch()
+ }
+ })
+ }).catch(() => {
+ this.$message.info('宸插彇娑堝垹闄�')
+ })
+ },
+ // 瀵硅瘽妗嗗叧闂簨浠�
+ handleClose() {
+ this.dialogForm.code = ''
+ this.dialogForm.name = ''
+ this.dialogForm.enable = 'Y'
+ this.dialogForm.description = ''
+ this.tableDataDialog = []
+ this.$refs.dialogForm.clearValidate()
+ },
+ // 瀵硅瘽妗嗗彇娑�
+ dialogVisibleCancel() {
+ this.dialogVisible = false
+ },
+ // 瀵硅瘽妗嗙‘璁�
+ dialogVisibleConfirm() {
+ this.$refs.dialogForm.validate(valid => {
+ if (valid) {
+ let Data = []
+ // 鏁扮粍涓璞$浉鍚岀殑鍘婚噸
+ Data = this.tableDataDialog.filter((currentValue, currentIndex, selfArr) => {
+ return selfArr.findIndex(item => item.checkitem_code === currentValue.checkitem_code) === currentIndex
+ })
+ Data.forEach((item, index) => {
+ item.checkitem_seq = index + 1
+ })
+ console.log(Data, 999)
+ const data = {
+ 'code': this.dialogForm.code,
+ 'name': this.dialogForm.name,
+ 'enable': this.dialogForm.enable,
+ 'description': this.dialogForm.description,
+ 'Data': Data
+ }
+ console.log(data, 111)
+ AddUpdateDeviceCheckStandArd(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
+ if (res.code === '200') {
+ this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '淇敼鎴愬姛锛�')
+ this.dialogVisible = false
+ this.getDeviceCheckStandArdSearch()
+ } else {
+ this.$message.error(this.operation === 'add' ? '娣诲姞澶辫触锛�' : '淇敼澶辫触锛�')
+ }
+ })
+ }
+ })
+ },
+
+ selectChange(val, row) {
+ row.chkdesc = this.checkItemSelectArr.find(item => {
+ return item.code === val || item.name === val
+ }).description
+
+ row.checkitem_code = this.checkItemSelectArr.find(item => {
+ return item.code === val || item.name === val
+ }).code
+ row.checkitem_name = this.checkItemSelectArr.find(item => {
+ return item.code === val || item.name === val
+ }).name
+ },
+ // 鏂板琛�
+ addRow() {
+ let flag = false
+ this.tableDataDialog.forEach(item => {
+ if (item.isVisible === 1) {
+ // return this.$message.info('璇峰厛纭鎴栧彇娑堜笂鏉¤褰曪紒')
+ flag = true
+ }
+ })
+ if (flag) {
+ return this.$message.info('璇峰厛纭鎴栧彇娑堜笂鏉¤褰曪紒')
+ }
+ this.tableDataDialog.push({
+ checkitem_code: '',
+ checkitem_name: '',
+ chkdesc: '',
+ isscan: 'Y',
+ cycle: 'D',
+ isVisible: 1
+ })
+ },
+ editRow(row) {
+ this.tableDataDialogSelected.forEach((item, index) => {
+ if (item === row.checkitem_code) {
+ this.tableDataDialogSelected.splice(index, 1)
+ }
+ })
+
+ this.tableDataDialog.forEach((item, index) => {
+ if (item.checkitem_code === row.checkitem_code) {
+ this.tableDataDialog.splice(index, 1, {
+ checkitem_code: row.checkitem_code,
+ checkitem_name: row.checkitem_name,
+ chkdesc: row.chkdesc,
+ isscan: row.isscan,
+ cycle: row.cycle,
+ isVisible: 1
+ })
+ }
+ })
+ },
+ delRow(row) {
+ this.tableDataDialog.forEach((item, index) => {
+ if (item.checkitem_code === row.checkitem_code) {
+ this.tableDataDialog.splice(index, 1)
+ }
+ })
+
+ this.tableDataDialogSelected.forEach((item, index) => {
+ if (item === row.checkitem_code) {
+ this.tableDataDialogSelected.splice(index, 1)
+ }
+ })
+ },
+ saveRow(row) {
+ if (this.tableDataDialogSelected.includes(row.checkitem_code)) {
+ return this.$message.info('鐐规閮ㄤ綅涓嶈兘閫夋嫨鐩稿悓锛�')
+ }
+ this.tableDataDialogSelected.push(row.checkitem_code)
+ row.isVisible = 0
+ console.log(this.tableDataDialog)
+ },
+ cancelRow(row) {
+ console.log(row, 111)
+ this.tableDataDialog.forEach((item, index) => {
+ if (item.checkitem_code === row.checkitem_code && item.isVisible === 1) {
+ console.log(item)
+ row.isVisible = 0
+ this.tableDataDialog.splice(index, 1)
+ }
+ })
+ },
+ // 鑾峰彇椤甸潰楂樺害
+ getHeight() {
+ this.$nextTick(() => {
+ this.mainHeight = window.innerHeight - 85
+ this.tableHeight = this.mainHeight - 200
+ })
+ },
+ tableRowClassName({ row, rowIndex }) {
+ return 'custom-row'
+ }
+ }
}
</script>
-<style scoped>
+<!--鍏叡椤甸潰鏍峰紡-->
+<style lang="scss" scoped>
+$main_color: #42b983;
+::v-deep .el-button--text {
+ font-size: 14px;
+ cursor: pointer;
+}
+.el-icon-share, .el-icon-delete, .el-icon-edit-outline {
+ color: $main_color;
+ cursor: pointer;
+}
+
+.el-icon-edit-outline {
+ margin-right: 15px;
+}
+
+::v-deep .el-button--primary, .el-button--default, .el-button--info {
+ height: 34px;
+ display: flex;
+ align-items: center;
+ padding: 0 15px;
+}
+
+::v-deep .el-button--primary {
+ //background-color: $main_color !important;
+}
+
+::v-deep .el-button--default {
+ background-color: #f8f8fa;
+ border: none;
+}
+
+::v-deep .el-input__inner {
+ height: 34px;
+ line-height: 34px;
+ //color: #a7a7a7;
+}
+
+//::v-deep .el-dialog__body {
+// padding: 20px 100px !important;
+//}
+::v-deep .el-dialog__body {
+ padding: 20px 20px !important;
+}
+
+::v-deep .dialogVisibleRoles .el-dialog__body {
+ padding: 20px 20px !important;
+}
+
+::v-deep .importPickerClass .el-dialog__body {
+ padding: 20px 20px !important;
+}
+
+::v-deep .el-dialog__footer {
+ display: flex;
+ justify-content: flex-end;
+}
+
+::v-deep .el-table .caret-wrapper {
+ transform: scale(0.8);
+}
+
+::v-deep .cell {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+}
+
+::v-deep .el-table::before {
+ height: 0;
+}
+
+::v-deep .el-table__body-wrapper {
+ background-color: #f8f8fa;
+}
+
+::v-deep .el-table__body .el-table__row.hover-row td {
+ background-color: #eaecef;
+}
+
+::v-deep .el-form--inline .el-form-item__label {
+ color: #a7a7a7;
+}
+
+.body ::v-deep .el-divider {
+ border: 1px solid #eee;
+ width: 99%;
+ margin: 10px auto;
+}
+
+.body ::v-deep .el-form-item {
+ margin-bottom: 0;
+}
+
+.userDialogVisible ::v-deep .el-form-item {
+ margin-bottom: 0;
+}
+::v-deep .el-select__caret{
+ display: flex;
+ align-items: center;
+ justify-content: center;
+}
+</style>
+<style>
+
+.el-table .custom-row {
+ background: #f8f8fa;
+}
</style>
--
Gitblit v1.9.3