123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831 |
- <template>
- <div class="app-container">
- <el-tabs v-model="activeName" @tab-click="handleClick">
- <el-tab-pane label="仪表盘" name="first">
- <div class="operation">
- <el-button class="success" @click="handleCreate">新增</el-button>
- </div>
- <div class="search">
- <el-input v-model="table.getdataListParm.parammaps.dname" placeholder="仪表盘名称" style="width: 180px;" class="filter-item" clearable />
- <el-select v-model="table.getdataListParm.parammaps.statue" placeholder="状态" class="filter-item" style="width: 120px;" clearable>
- <el-option v-for="item in statueList" :key="item.id" :label="item.value" :value="item.id" />
- </el-select>
- <el-button class="successBorder" @click="handleSearch">查询</el-button>
- <el-button class="successBorder" @click="handleRefresh">重置</el-button>
- </div>
- <div class="table">
- <el-form ref="form" :rules="table.rules" :model="table">
- <el-table :key="table.tableKey" v-loading="table.listLoading" element-loading-text="给我一点时间" :data="table.list" border fit highlight-current-row style="width: 100%;" :row-style="rowStyle" :cell-style="cellStyle" class="elTable table-fixed">
- <!-- <el-table-column type="selection" align="center" width="50" /> -->
- <el-table-column label="序号" align="center" type="index" width="50px">
- <template slot-scope="scope">
- <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="仪表盘名称" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.dname }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.dname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:0 10px;" maxlength="32" />
- </template>
- </el-table-column>
- <el-table-column label="仪表盘描述" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.display }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.display" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:0 10px;" maxlength="32" />
- </template>
- </el-table-column>
- <el-table-column label="状态" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit && scope.row.statue == 1">公开</span>
- <span v-if="scope.row.NoEdit && scope.row.statue == 0">私有</span>
- <el-select v-if="scope.row.Edit" v-model="scope.row.statue" filterable placeholder="状态" class="filter-item" style="width:95%;padding:10px 0;" @change="changeStatue">
- <el-option v-for="item in statueList" :key="item.id" :label="item.value" :value="item.id" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="分发角色" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.rolenames }}</span>
- <el-select v-if="scope.row.Edit" v-model="scope.row.rolenamesId" multiple filterable placeholder="分发角色" class="filter-item" style="width:95%;padding:10px 0;" @change="changeRole">
- <el-option v-for="item in roleList" :key="item.id" :label="item.rolename" :value="item.id" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="显示到菜单" min-width="110px" align="center">
- <template slot-scope="scope">
- <el-switch v-model="scope.row.reportenable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
- </template>
- </el-table-column>
- <el-table-column label="创建人" min-width="200px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.emp }}</span>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" min-width="200px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.opratetime }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <!-- 跳转页面 -->
- <el-button class="miniSuccess" @click="jumpSee(row)">查看</el-button>
- <!-- <el-button class="miniSuccess" :disabled="row.empid != empid" @click="jumpEdit(row)">修改仪表盘</el-button> -->
- <!-- 新增 -->
- <el-button v-if="row.isCreate" class="miniSuccess" :disabled="isokDisable" @click="createData(row)">保存</el-button>
- <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
- <!-- 编辑 -->
- <el-button v-if="row.isUpdate" class="miniSuccess" :disabled="row.empid != empid" @click="handleUpdate(row)">编辑</el-button>
- <el-button v-if="row.isUpdate" class="miniDanger" :disabled="row.empid != empid" @click="handleRowDelete(row)">删除</el-button>
- <!-- 编辑保存 -->
- <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
- <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
- </div>
- </el-tab-pane>
- <el-tab-pane label="图表" name="second">
- <div class="operation">
- <el-button class="success" @click="handleCreate2">新增</el-button>
- </div>
- <div class="search">
- <el-input v-model="table2.getdataListParm.parammaps.dname" placeholder="图表名称" style="width: 180px;" class="filter-item" clearable />
- <el-select v-model="table2.getdataListParm.parammaps.statue" placeholder="状态" class="filter-item" style="width: 120px;" clearable>
- <el-option v-for="item in statueList2" :key="item.id" :label="item.value" :value="item.id" />
- </el-select>
- <el-button class="successBorder" @click="handleSearch2">查询</el-button>
- <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
- </div>
- <div class="table">
- <el-form ref="form" :rules="table2.rules" :model="table2">
- <el-table :key="table2.tableKey" v-loading="table2.listLoading" element-loading-text="给我一点时间" :data="table2.list" border fit highlight-current-row style="width: 100%;" :row-style="rowStyle" :cell-style="cellStyle" class="elTable table-fixed">
- <!-- <el-table-column type="selection" align="center" width="50" /> -->
- <el-table-column label="序号" align="center" type="index" width="50px">
- <template slot-scope="scope">
- <span>{{ scope.$index + (table2.pageNum-1) * table2.pageSize + 1 }}</span>
- </template>
- </el-table-column>
- <el-table-column label="图表名称" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.cname }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.cname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:0 10px;" maxlength="32" />
- </template>
- </el-table-column>
- <el-table-column label="图表描述" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit">{{ scope.row.display }}</span>
- <el-input v-if="scope.row.Edit" v-model="scope.row.display" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:95%;padding:0 10px;" maxlength="32" />
- </template>
- </el-table-column>
- <el-table-column label="状态" min-width="200px" align="center">
- <template slot-scope="scope">
- <span v-if="scope.row.NoEdit && scope.row.statue == 1">公开</span>
- <span v-if="scope.row.NoEdit && scope.row.statue == 0">私有</span>
- <el-select v-if="scope.row.Edit" v-model="scope.row.statue" filterable placeholder="状态" class="filter-item" style="width:95%;padding:10px 0;" @change="changeStatue2">
- <el-option v-for="item in statueList" :key="item.id" :label="item.value" :value="item.id" />
- </el-select>
- </template>
- </el-table-column>
- <el-table-column label="创建人" min-width="200px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.emp }}</span>
- </template>
- </el-table-column>
- <el-table-column label="创建时间" min-width="200px" align="center">
- <template slot-scope="scope">
- <span>{{ scope.row.opratetime }}</span>
- </template>
- </el-table-column>
- <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
- <template slot-scope="{row}">
- <!-- 跳转页面 -->
- <el-button class="miniSuccess" @click="jumpSee2(row)">查看</el-button>
- <el-button class="miniSuccess" :disabled="row.empid != empid" @click="jumpEdit2(row)">修改图表</el-button>
- <!-- 新增 -->
- <el-button v-if="row.isCreate" class="miniSuccess" :disabled="isokDisable" @click="createData2(row)">保存</el-button>
- <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
- <!-- 编辑 -->
- <el-button v-if="row.isUpdate" class="miniSuccess" :disabled="row.empid != empid" @click="handleUpdate2(row)">编辑</el-button>
- <el-button v-if="row.isUpdate" class="miniDanger" :disabled="row.empid != empid" @click="handleRowDelete2(row)">删除</el-button>
- <!-- 编辑保存 -->
- <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData2(row)">保存</el-button>
- <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
- </template>
- </el-table-column>
- </el-table>
- </el-form>
- <pagination v-show="table2.total>=0" :total="table2.total" :page.sync="table2.getdataListParm.offset" :limit.sync="table2.getdataListParm.pagecount" @pagination="getList2" />
- </div>
- </el-tab-pane>
- </el-tabs>
- <el-dialog title="新增看仪表盘" width="750px" :visible.sync="editDialogVisible">
- <el-form label-width="160px">
- <el-form-item label="仪表盘名称">
- <el-input v-model="dbObj.dname" size="small" style="width: 450px;" placeholder="请输入仪表盘名称" />
- </el-form-item>
- <el-form-item label="仪表盘描述">
- <el-input v-model="dbObj.display" type="textarea" :rows="5" size="small" style="width: 450px;" placeholder="请输入仪表盘描述" />
- </el-form-item>
- </el-form>
- <span slot="footer" class="dialog-footer">
- <el-button type="primary" size="small" @click="editDialogVisible = false">取消</el-button>
- <el-button type="primary" size="small" @click="handleSubmit"> 确认</el-button>
- </span>
- </el-dialog>
- </div>
- </template>
- <script>
- import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
- import Cookies from 'js-cookie'
- import Pagination from '@/components/Pagination'
- import { MessageBox } from 'element-ui'
- export default {
- name: 'BoardEchartManagement',
- components: { Pagination },
- data() {
- return {
- empid: Cookies.get('employeid'),
- editDialogVisible: false,
- dbObj: {},
- // requestParams: [
- // { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
- // ],
- requestParams: [
- { name: 'getRoleAll', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') } }
- ],
- statueList: [{ id: "1", value: '公开' }, { id: "0", value: '私有' }],
- statueList2: [{ id: "1", value: '公开' }, { id: "0", value: '私有' }],
- roleList: [],
- rolenamesIdTempArr: [],
- table: {
- rules: {
- name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
- },
- getdataListParm: {
- name: 'getDashboardList',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- dname: '',
- statue: '',
- empid: Cookies.get('employeid')
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- temp: {}
- },
- table2: {
- rules: {
- name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
- },
- getdataListParm: {
- name: 'getChartList',
- page: 1,
- offset: 1,
- pagecount: 10,
- returntype: 'Map',
- parammaps: {
- pastureid: Cookies.get('pastureid'),
- cname: '',
- statue: '',
- empid: Cookies.get('employeid')
- }
- },
- tableKey: 0,
- list: [],
- total: 0,
- listLoading: true,
- temp: {}
- },
- requestParam: {},
- isokDisable: false,
- selectList: [],
- rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
- cellStyle: { padding: 0 + 'px' },
- activeName: 'first'
- }
- },
- created() {
- this.getList()
- this.getList2()
- this.getDownList()
- if (this.$route.params.tab == 'second') {
- this.activeName = 'second'
- } else {
- this.activeName = 'first'
- }
- },
- methods: {
- handleClick(tab, event) {
- console.log(tab, event)
- },
- getDownList() {
- GetDataByNames(this.requestParams).then(response => {
- console.log('下拉框数据', response.data)
- this.roleList = response.data.getRoleAll.list
- })
- },
- getList() {
- this.table.listLoading = true
- console.log(this.table.getdataListParm)
- GetDataByName(this.table.getdataListParm).then(response => {
- console.log('table数据', response.data.list)
- if (response.data.list !== null) {
- for (let i = 0; i < response.data.list.length; i++) {
- this.$set(response.data.list[i], 'Edit', false) // 编辑
- this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
- this.$set(response.data.list[i], 'isCreate', false) // 新增操作
- this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
- this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
- }
- var arr = response.data.list
- arr.map(function (i, j) {
- if (i.roleids) {
- return i.rolenamesId = i.roleids.split(",")
- } else {
- return i.rolenamesId = []
- }
- })
- arr.map(function (i, j) {
- if (i.roleids) {
- return i.rolenamesId2B = i.roleids.split(",")
- } else {
- return i.rolenamesId2B = []
- }
- })
- this.table.list = arr
- this.table.pageNum = response.data.pageNum
- this.table.pageSize = response.data.pageSize
- this.table.total = response.data.total
- } else {
- this.table.list = []
- }
- setTimeout(() => {
- this.table.listLoading = false
- }, 100)
- })
- },
- getList2() {
- this.table2.listLoading = true
- console.log(this.table2.getdataListParm)
- GetDataByName(this.table2.getdataListParm).then(response => {
- console.log('table2数据', response.data.list)
- if (response.data.list !== null) {
- for (let i = 0; i < response.data.list.length; i++) {
- this.$set(response.data.list[i], 'Edit', false) // 编辑
- this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
- this.$set(response.data.list[i], 'isCreate', false) // 新增操作
- this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
- this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
- }
- this.table2.list = response.data.list
- this.table2.pageNum = response.data.pageNum
- this.table2.pageSize = response.data.pageSize
- this.table2.total = response.data.total
- } else {
- this.table2.list = []
- }
- setTimeout(() => {
- this.table2.listLoading = false
- }, 100)
- })
- },
- handleEnableChange(val) {
- console.log('点击了是否启用', val)
- },
- handleSearch() {
- console.log('点击了查询')
- this.table.getdataListParm.offset = 1
- this.getList()
- },
- handleSearch2() {
- console.log('点击了查询')
- this.table2.getdataListParm.offset = 1
- this.getList2()
- },
- handleRefresh() {
- console.log('点击了重置')
- this.table.getdataListParm.parammaps.cname = ''
- this.table.getdataListParm.parammaps.dname = ''
- this.table.getdataListParm.parammaps.statue = ''
- this.table.getdataListParm.offset = 1
- this.getList()
- },
- handleRefresh2() {
- console.log('点击了重置')
- this.table2.getdataListParm.parammaps.cname = ''
- this.table2.getdataListParm.parammaps.dname = ''
- this.table2.getdataListParm.parammaps.statue = ''
- this.table2.getdataListParm.offset = 1
- this.getList2()
- },
- // changeParent(val) {
- // console.log('点击了牲畜类别父类', val)
- // console.log(this.parentList.find(obj => obj.value == val).label)
- // this.table.temp.parentname = this.parentList.find(obj => obj.value == val).label
- // },id
- changeStatue(val) {
- console.log('点击了状态', val)
- // console.log(this.statueList.find(obj => obj.value == val).id)
- this.table.temp.statueid = val
- this.table.temp.statue = val
- },
- changeStatue2(val) {
- console.log('点击了状态', val)
- // console.log(this.statueList.find(obj => obj.value == val).id)
- this.table2.temp.statueid = val
- this.table2.temp.statue = val
- },
- changeRole(val) {
- console.log('点击了角色', val)
- console.log('this.table.list', this.table.list)
- var arr = []
- this.roleList.forEach(function (i) {
- val.forEach(function (j) {
- if (i.id == j) {
- arr.push(i)
- }
- })
- })
- console.log('点击了角色', arr)
- this.table.temp.rolenamesId = arr
- this.rolenamesIdTempArr = arr
- },
- handleCreate() {
- this.editDialogVisible = true
- },
- handleSubmit() {
- var data = {
- name: 'insertDashboard',
- parammaps: {
- dname: this.dbObj.dname,
- display: this.dbObj.display,
- pastureid: Cookies.get('pastureid'),
- empid: Cookies.get('employeid'),
- emp: Cookies.get('employename')
- }
- }
- PostDataByName(data).then(res => {
- console.log('新增保存发送参数', data)
- this.$message({
- type: 'success',
- message: this.$t('common.saveSuccess')
- })
- this.editDialogVisible = false
- console.log('res', res)
- if (res.data.LastInsertId) {
- this.$router.push({ name: 'Addboard', params: { id: res.data.LastInsertId, isEdit: 'create' } })
- Cookies.set('AddboardIsEdit', 'create')
- Cookies.set('AddboardIsEditId', res.data.LastInsertId)
- localStorage.setItem("AddboardIsEditId", res.data.LastInsertId)
- }
- })
- },
- createData(row) {
- console.log('点击了新增保存')
- this.table.temp.pastureid = Cookies.get('pastureid')
- this.table.temp.dname = row.dname
- this.table.temp.display = row.display
- this.table.temp.statue = row.statue
- this.table.temp.reportenable = row.reportenable
- this.table.temp.emp = row.emp
- this.table.temp.opratetime = row.opratetime
- // 仪表盘名称/状态是否为空
- if (this.table.temp.dname == '' && this.table.temp.statue == '') {
- this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
- return false
- } else if (this.table.temp.dname == '') {
- this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
- return false
- }
- const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
- if (pattern.test(this.table.temp.dname)) {
- this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
- return false
- }
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- this.requestParam.name = 'insertDashboard'
- this.requestParam.parammaps = this.table.temp
- PostDataByName(this.requestParam).then(response => {
- console.log('新增保存发送参数', this.requestParam)
- if (response.msg !== 'fail') {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- this.getList()
- } else {
- failproccess(response, this.$notify)
- }
- })
- },
- createCancel(row) {
- console.log('点击了新增取消')
- for (let i = 0; i < this.table.list.length; i++) {
- if (row.myId === this.table.list[i].myId) {
- var listIndex = this.table.list.indexOf(this.table.list[i])
- }
- if (listIndex > -1) {
- this.table.list.splice(listIndex, 1)
- return
- }
- }
- },
- handleCreate2(row) {
- this.$router.push({ name: 'ChartPanel', params: { id: 'create', isEdit: 'edit' } })
- Cookies.set('ChartPanelIsEdit', 'edit')
- Cookies.set('ChartPanelIsEditId', 'create')
- },
- jumpSee(row) {
- console.log('点击了查看', row)
- this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'view' } })
- Cookies.set('AddboardIsEdit', 'view')
- Cookies.set('AddboardIsEditId', row.id)
- localStorage.setItem("AddboardIsEditId", row.id)
- },
- jumpEdit(row) {
- console.log('点击了编辑', row)
- this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'edit' } })
- Cookies.set('AddboardIsEdit', 'edit')
- Cookies.set('AddboardIsEditId', row.id)
- localStorage.setItem("AddboardIsEditId", row.id)
- },
- jumpSee2(row) {
- console.log('点击了查看', row)
- this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'view' } })
- Cookies.set('ChartPanelIsEdit', 'view')
- Cookies.set('ChartPanelIsEditId', row.id)
- localStorage.setItem("ChartPanelIsEditId", row.id)
- },
- jumpEdit2(row) {
- console.log('点击了编辑', row)
- this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'edit' } })
- Cookies.set('ChartPanelIsEdit', 'edit')
- Cookies.set('ChartPanelIsEditId', row.id)
- localStorage.setItem("ChartPanelIsEditId", row.id)
- },
- handleUpdate(row) {
- console.log('点击了设置', row)
- for (let i = 0; i < this.table.list.length; i++) {
- if (this.table.list[i].Edit == true) {
- this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
- return false
- }
- }
- // 编辑true,不可编辑false
- row.Edit = true
- row.NoEdit = false
- // 新增false,编辑false,编辑保存true
- row.isCreate = false
- row.isUpdate = false
- row.isUpdateSave = true
- // console.log(row.parentid)
- row.statue = String(row.statue)
- console.log("row.statue ", row.statue)
- this.table.temp.statue = row.statue
- this.table.temp.statueid = row.statueid
- this.table.temp.parentname = row.parentname
- },
- handleUpdate2(row) {
- console.log('点击了设置', row)
- for (let i = 0; i < this.table2.list.length; i++) {
- if (this.table2.list[i].Edit == true) {
- this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
- return false
- }
- }
- // 编辑true,不可编辑false
- row.Edit = true
- row.NoEdit = false
- // 新增false,编辑false,编辑保存true
- row.isCreate = false
- row.isUpdate = false
- row.isUpdateSave = true
- // console.log(row.parentid)
- row.statue = String(row.statue)
- this.table2.temp.statue = row.statue
- this.table2.temp.statueid = row.statueid
- },
- updateData(row) {
- console.log('点击了编辑保存')
- this.table.temp.pastureid = Cookies.get('pastureid')
- this.table.temp.dname = row.dname
- this.table.temp.display = row.display
- this.table.temp.reportenable = row.reportenable
- this.table.temp.emp = row.emp
- this.table.temp.opratetime = row.opratetime
- this.table.temp.id = row.id
- this.table.temp.statue = row.statue
- this.table.temp.rolenamesId = row.rolenamesId
- console.log(this.table.temp.rolenamesId)
- var rolenamesIdArr = []
- this.table.temp.rolenamesId.forEach(function (i, j) {
- rolenamesIdArr.push({ "id": i })
- })
- // 仪表盘名称/状态是否为空
- if (this.table.temp.dname == '' && this.table.temp.statue == '') {
- this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
- return false
- } else if (this.table.temp.dname == '') {
- this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
- return false
- }
- const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
- if (pattern.test(this.table.temp.dname)) {
- this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
- return false
- }
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- console.log(this.table.temp)
- var send_data3 = {
- 'common': { 'returnmap': '0' },
- 'data': [
- {
- 'name': 'updateDashboard',
- 'type': 'e',
- 'parammaps': this.table.temp
- },
- {
- 'name': 'deleteDrole',
- 'type': 'e',
- 'parammaps': {
- 'id': row.id,
- 'pastureid': Cookies.get('pastureid')
- }
- },
- {
- 'name': 'insertSpotList',
- 'resultmaps': {
- 'list': rolenamesIdArr
- },
- 'children': [
- {
- 'name': 'insertDrole',
- 'type': 'e',
- 'parammaps':
- {
- 'id': row.id,
- 'pastureid': Cookies.get('pastureid'),
- 'roleid': '@insertSpotList.id'
- }
- }
- ]
- }
- ]
- }
- ExecDataByConfig(send_data3).then(response => {
- if (response.msg !== 'fail') {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- this.getList()
- } else {
- failproccess(response, this.$notify)
- }
- })
- },
- updateData2(row) {
- console.log('点击了编辑保存')
- this.table2.temp.pastureid = Cookies.get('pastureid')
- this.table2.temp.cname = row.cname
- this.table2.temp.display = row.display
- this.table2.temp.emp = row.emp
- this.table2.temp.opratetime = row.opratetime
- this.table2.temp.id = row.id
- this.table2.temp.statue = row.statue
- // 仪表盘名称/状态是否为空
- if (this.table2.temp.dname == '' && this.table.temp.statue == '') {
- this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
- return false
- } else if (this.table2.temp.dname == '') {
- this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
- return false
- }
- const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
- if (pattern.test(this.table2.temp.dname)) {
- this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
- return false
- }
- this.isokDisable = true
- setTimeout(() => {
- this.isokDisable = false
- }, 1000)
- console.log(this.table2.temp)
- var send_data3 = {
- 'name': 'updateChart',
- 'parammaps': this.table2.temp
- }
- PostDataByName(send_data3).then(response => {
- console.log('新增保存发送参数', send_data3)
- if (response.msg !== 'fail') {
- this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
- this.getList2()
- } else {
- failproccess(response, this.$notify)
- }
- })
- },
- updateCancel(row) {
- console.log('点击了编辑取消')
- // 编辑false,不可编辑true
- row.Edit = false
- row.NoEdit = true
- // 新增false,编辑true,编辑保存false
- row.isCreate = false
- row.isUpdate = true
- row.isUpdateSave = false
- row.rolenamesId = row.rolenamesId2B
- },
- updateCancel2(row) {
- console.log('点击了编辑取消')
- // 编辑false,不可编辑true
- row.Edit = false
- row.NoEdit = true
- // 新增false,编辑true,编辑保存false
- row.isCreate = false
- row.isUpdate = true
- row.isUpdateSave = false
- },
- handleRowDelete(row) {
- console.log('点击了行内删除')
- MessageBox.confirm('是否确认删除此信息?', {
- confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- this.requestParam.name = 'deleteDashboard'
- this.requestParam.parammaps = {}
- this.requestParam.parammaps.pastureid = row.pastureid
- this.requestParam.parammaps.id = row.id
- PostDataByName(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
- this.getList()
- }
- })
- }).catch(() => {
- this.$message({ type: 'info', message: '已取消删除' })
- })
- },
- handleRowDelete2(row) {
- console.log('点击了行内删除')
- MessageBox.confirm('是否确认删除此信息?', {
- confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
- }).then(() => {
- this.requestParam.name = 'deleteChart'
- this.requestParam.parammaps = {}
- this.requestParam.parammaps.pastureid = row.pastureid
- this.requestParam.parammaps.id = row.id
- PostDataByName(this.requestParam).then(response => {
- if (response.msg === 'fail') {
- this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
- } else {
- this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
- this.getList2()
- }
- })
- }).catch(() => {
- this.$message({ type: 'info', message: '已取消删除' })
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .search {
- margin-top: 10px;
- }
- .table {
- margin-top: 10px;
- }
- </style>
|