|
|
@@ -0,0 +1,350 @@
|
|
|
+<template>
|
|
|
+ <div>
|
|
|
+ <el-breadcrumb class="heading">
|
|
|
+ <el-breadcrumb-item :to="{ path: '/' }">平台首页</el-breadcrumb-item>
|
|
|
+ <el-breadcrumb-item :to="{ path: '/setting/systemitems' }">数据字典</el-breadcrumb-item>
|
|
|
+ <el-breadcrumb-item>数据字典详情</el-breadcrumb-item>
|
|
|
+ </el-breadcrumb>
|
|
|
+
|
|
|
+ <el-card class="box-card">
|
|
|
+ <div slot="header">
|
|
|
+ <span>
|
|
|
+ <i class="icon icon-table2"></i> 数据字典详情 {{titlename}}
|
|
|
+ </span>
|
|
|
+ <span style="float: right">
|
|
|
+ <el-button size="small"
|
|
|
+ type="primary"
|
|
|
+ @click="opendatadialog(1,null,-1)">添加设备默认检测周期</el-button>
|
|
|
+ <el-button type="primary"
|
|
|
+ class="el-button--small"
|
|
|
+ onclick="window.history.go(-1)">返回</el-button>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <el-table :data="list"
|
|
|
+ border
|
|
|
+ style="width: 100%">
|
|
|
+ <el-table-column label="操作"
|
|
|
+ width="65">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <el-button size="small"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-edit"
|
|
|
+ title="编辑字典"
|
|
|
+ @click="opendatadialog(2,scope.row,scope.$index);"></el-button>
|
|
|
+ <el-button size="small"
|
|
|
+ style="margin-left:3px;"
|
|
|
+ type="text"
|
|
|
+ icon="el-icon-delete"
|
|
|
+ title="删除"
|
|
|
+ @click="deletedata(scope.row)"></el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="Name"
|
|
|
+ label="设备名称"
|
|
|
+ show-overflow-tooltip></el-table-column>
|
|
|
+ <el-table-column label="检测周期"
|
|
|
+ show-overflow-tooltip>
|
|
|
+ <template slot-scope="scope">
|
|
|
+ {{scope.row.DetectionNum+scope.row.DetectionUnit}}
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-card>
|
|
|
+
|
|
|
+ <el-dialog :title="dialogtitle"
|
|
|
+ :visible.sync="datadialogVisible">
|
|
|
+ <el-form :model="itemsdetailinfoform"
|
|
|
+
|
|
|
+ ref="itemsdetailinfoform">
|
|
|
+ <el-form-item label="设备分类"
|
|
|
+ label-width="120px" required>
|
|
|
+ <el-select v-model="projectTypeId"
|
|
|
+ :disabled="disableFlag"
|
|
|
+ @change="projectTypeChange"
|
|
|
+ style="width:100%"
|
|
|
+ clearable
|
|
|
+ filterable
|
|
|
+ placeholder="请选择设备分类" >
|
|
|
+ <el-option v-for="item in projectTypeList"
|
|
|
+ :key="item.Id"
|
|
|
+ :label="item.FullName"
|
|
|
+ :value="item.Id"></el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="检测周期数值"
|
|
|
+ label-width="120px" required>
|
|
|
+ <el-input-number v-model="itemsdetailinfoform.DetectionNum"
|
|
|
+ :min="1"
|
|
|
+ style="width:100%"></el-input-number>
|
|
|
+ </el-form-item>
|
|
|
+
|
|
|
+ <el-form-item label="检测周期单位"
|
|
|
+ label-width="120px" required>
|
|
|
+ <el-select v-model="detectionUnit"
|
|
|
+ @change="detectionUnitChange"
|
|
|
+ style="width:100%"
|
|
|
+ placeholder="请选择">
|
|
|
+ <el-option v-for="item in detectionUnitOptions"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value">
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div slot="footer"
|
|
|
+ class="dialog-footer">
|
|
|
+ <el-button @click="datadialogVisible = false">取 消</el-button>
|
|
|
+ <el-button type="primary"
|
|
|
+ @click="savedata('itemsdetailinfoform')">确 定</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
+
|
|
|
+ </div>
|
|
|
+
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ name: 'itemsdetail',
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ projectTypeId: '',
|
|
|
+ Id: 0,
|
|
|
+ testTypeList: [],
|
|
|
+ projectTypeList: [],
|
|
|
+ titlename: '',
|
|
|
+ disableFlag: false,
|
|
|
+ currentItemCount: 0,
|
|
|
+ currentPage: 1,
|
|
|
+ size: 10,
|
|
|
+ detectionUnit: '天',
|
|
|
+
|
|
|
+ detectionUnitOptions: [{
|
|
|
+ value: '天',
|
|
|
+ label: '天'
|
|
|
+ }, {
|
|
|
+ value: '月',
|
|
|
+ label: '月'
|
|
|
+ }, {
|
|
|
+ value: '年',
|
|
|
+ label: '年'
|
|
|
+ }],
|
|
|
+
|
|
|
+ dialogtitle: '',
|
|
|
+ itemsdetailinfoform: {
|
|
|
+ Name: '',
|
|
|
+ pid: 0,
|
|
|
+ DetectionNum: 1,
|
|
|
+ DetectionUnit: ''
|
|
|
+
|
|
|
+ },
|
|
|
+ list: [],
|
|
|
+ datadialogVisible: false
|
|
|
+ // rulesitemsdetailinfoform: {
|
|
|
+
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ let _this = this
|
|
|
+ let titlename = this.$route.query.name
|
|
|
+ if (titlename !== undefined) {
|
|
|
+ this.titlename = `【字典名-${titlename}】`
|
|
|
+ }
|
|
|
+ _this.initData()
|
|
|
+ _this.getProjectType()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ projectTypeChange (val) {
|
|
|
+ let _this = this
|
|
|
+ _this.itemsdetailinfoform.pid = val
|
|
|
+ let obj = {}
|
|
|
+ obj = _this.projectTypeList.find((item) => {
|
|
|
+ return item.Id === val
|
|
|
+ })
|
|
|
+ _this.itemsdetailinfoform.Name = obj.FullName
|
|
|
+ },
|
|
|
+ detectionUnitChange (val) {
|
|
|
+ let _this = this
|
|
|
+ _this.itemsdetailinfoform.DetectionUnit = val
|
|
|
+ },
|
|
|
+ getProjectType () {
|
|
|
+ let _this = this
|
|
|
+ _this.$axios.get('/testtype/testypetreeall', {})
|
|
|
+ .then(res => {
|
|
|
+ _this.testTypeList = res.data.items
|
|
|
+ if (!_this.testTypeList) {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ for (var i = 0; i < _this.testTypeList.length; i++) {
|
|
|
+ if (_this.testTypeList[i].ParentId === 0) {
|
|
|
+ _this.projectTypeList.push(_this.testTypeList[i])
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ initData () {
|
|
|
+ let _this = this
|
|
|
+ const params = { _currentPage: _this.currentPage, _size: _this.size }
|
|
|
+
|
|
|
+ _this.$axios.get('/items/getdetectionmodel/', { params })
|
|
|
+ .then(res => {
|
|
|
+ console.log(res)
|
|
|
+ _this.list = res.data.items
|
|
|
+ _this.currentItemCount = res.data.currentItemCount
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ clearitemsdetailinfoform () {
|
|
|
+ let _this = this
|
|
|
+ _this.projectTypeId = ''
|
|
|
+ _this.detectionUnit = '天'
|
|
|
+ _this.itemsdetailinfoform.DetectionNum = 1
|
|
|
+ },
|
|
|
+ deletedata (val) {
|
|
|
+ let _this = this
|
|
|
+ _this.$confirm('此操作将永久删除该数据, 是否继续?', '提示', {
|
|
|
+ confirmButtonText: '确定',
|
|
|
+ cancelButtonText: '取消',
|
|
|
+ type: 'warning'
|
|
|
+ }).then(() => {
|
|
|
+ _this.$axios.delete('/items/deletedetectionmodel/' + val.Id, null)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ _this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: res.data.message
|
|
|
+ })
|
|
|
+ this.initData(this.$route.params.opera)
|
|
|
+ } else {
|
|
|
+ _this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: res.data.message
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => { })
|
|
|
+ }).catch(() => { })
|
|
|
+ },
|
|
|
+ opendatadialog (item, v, index) {
|
|
|
+ let _this = this
|
|
|
+ _this.operatingitem = item // 判断添加删除的
|
|
|
+ _this.datadialogVisible = true
|
|
|
+ _this.clearitemsdetailinfoform()
|
|
|
+ if (item === 1) {
|
|
|
+ _this.dialogtitle = '添加'
|
|
|
+ _this.disableFlag = false
|
|
|
+ } else if (item === 2) {
|
|
|
+ _this.dialogtitle = `编辑`
|
|
|
+ _this.Id = v.Id
|
|
|
+ _this.projectTypeId = v.Pid
|
|
|
+ _this.disableFlag = true
|
|
|
+ _this.detectionUnit = v.DetectionUnit
|
|
|
+
|
|
|
+ _this.itemsdetailinfoform.DetectionUnit = v.DetectionUnit
|
|
|
+ _this.itemsdetailinfoform.DetectionNum = v.DetectionNum
|
|
|
+ }
|
|
|
+ },
|
|
|
+ savedata (formName) {
|
|
|
+ let _this = this
|
|
|
+ this.$refs[formName].validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ if (_this.operatingitem === 1) {
|
|
|
+ this.$axios.post('/items/adddetectionmodel', _this.itemsdetailinfoform)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ _this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: res.data.message
|
|
|
+ })
|
|
|
+ _this.datadialogVisible = false
|
|
|
+ this.initData()
|
|
|
+ } else {
|
|
|
+ _this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: res.data.message
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(err => {
|
|
|
+ console.error(err)
|
|
|
+ })
|
|
|
+ } else if (_this.operatingitem === 2) {
|
|
|
+ _this.$axios.post('items/editdetectionmodel/' + _this.Id, _this.itemsdetailinfoform)
|
|
|
+ .then(res => {
|
|
|
+ if (res.data.code === 0) {
|
|
|
+ _this.$message({
|
|
|
+ type: 'success',
|
|
|
+ message: res.data.message
|
|
|
+ })
|
|
|
+ _this.datadialogVisible = false
|
|
|
+ this.initData()
|
|
|
+ } else {
|
|
|
+ _this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: res.data.message
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .catch(() => { })
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss">
|
|
|
+.time {
|
|
|
+ font-size: 13px;
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+.bottom {
|
|
|
+ margin-top: 13px;
|
|
|
+ line-height: 12px;
|
|
|
+}
|
|
|
+.button {
|
|
|
+ padding: 0;
|
|
|
+ float: right;
|
|
|
+}
|
|
|
+.image {
|
|
|
+ width: 100%;
|
|
|
+ display: block;
|
|
|
+}
|
|
|
+.clearfix:before,
|
|
|
+.clearfix:after {
|
|
|
+ display: table;
|
|
|
+ content: "";
|
|
|
+}
|
|
|
+.clearfix:after {
|
|
|
+ clear: both;
|
|
|
+}
|
|
|
+.el-pagination {
|
|
|
+ margin: 1rem 0 2rem;
|
|
|
+ text-align: right;
|
|
|
+}
|
|
|
+.plab {
|
|
|
+ font-size: 13px;
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+.triggerone {
|
|
|
+ font-size: 13px;
|
|
|
+ margin-left: 80px;
|
|
|
+}
|
|
|
+.plab {
|
|
|
+ font-size: 13px;
|
|
|
+ color: #999;
|
|
|
+}
|
|
|
+</style>
|