d2e08171d0f1046a322f2f923e10d783edf6fb6b.svn-base 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771
  1. <template>
  2. <div class="app-container">
  3. <el-tabs v-model="activeName" @tab-click="handleClick">
  4. <el-tab-pane label="仪表盘" name="first">
  5. <div class="operation">
  6. <el-button class="success" @click="handleCreate">新增</el-button>
  7. </div>
  8. <div class="search">
  9. <el-input v-model="table.getdataListParm.parammaps.dname" placeholder="仪表盘名称" style="width: 180px;" class="filter-item" clearable />
  10. <el-select v-model="table.getdataListParm.parammaps.statue" placeholder="状态" class="filter-item" style="width: 120px;" clearable>
  11. <el-option v-for="item in statueList" :key="item.id" :label="item.value" :value="item.id" />
  12. </el-select>
  13. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  14. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  15. </div>
  16. <div class="table">
  17. <el-form ref="form" :rules="table.rules" :model="table">
  18. <el-table
  19. :key="table.tableKey"
  20. v-loading="table.listLoading"
  21. element-loading-text="给我一点时间"
  22. :data="table.list"
  23. border
  24. fit
  25. highlight-current-row
  26. style="width: 100%;"
  27. :row-style="rowStyle"
  28. :cell-style="cellStyle"
  29. class="elTable table-fixed"
  30. >
  31. <!-- <el-table-column type="selection" align="center" width="50" /> -->
  32. <el-table-column label="序号" align="center" type="index" width="50px">
  33. <template slot-scope="scope">
  34. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="仪表盘名称" min-width="200px" align="center">
  38. <template slot-scope="scope">
  39. <span v-if="scope.row.NoEdit">{{ scope.row.dname }}</span>
  40. <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" />
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="仪表盘描述" min-width="200px" align="center">
  44. <template slot-scope="scope">
  45. <span v-if="scope.row.NoEdit">{{ scope.row.display }}</span>
  46. <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" />
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="状态" min-width="200px" align="center">
  50. <template slot-scope="scope">
  51. <span v-if="scope.row.NoEdit">{{ scope.row.statue == 1 ? "公开" : "私有" }}</span>
  52. <el-select v-if="scope.row.Edit" v-model="scope.row.statueid" filterable placeholder="状态" class="filter-item" style="width:95%;padding:10px 0;" @change="changeStatue">
  53. <el-option v-for="item in statueList" :key="item.id" :label="item.value" :value="item.id" />
  54. </el-select>
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="分发角色" min-width="200px" align="center">
  58. <template slot-scope="scope">
  59. <span v-if="scope.row.NoEdit">{{ scope.row.rolenames }}</span>
  60. <el-select v-if="scope.row.Edit" v-model="scope.row.rolenames" multiple filterable placeholder="分发角色" class="filter-item" style="width:95%;padding:10px 0;" @change="changeRole">
  61. <el-option v-for="item in roleList" :key="item.id" :label="item.rolename" :value="item.id" />
  62. </el-select>
  63. </template>
  64. </el-table-column>
  65. <el-table-column label="报表显示" min-width="110px" align="center">
  66. <template slot-scope="scope">
  67. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="创建人" min-width="200px" align="center">
  71. <template slot-scope="scope">
  72. <span>{{ scope.row.emp }}</span>
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="创建时间" min-width="200px" align="center">
  76. <template slot-scope="scope">
  77. <span>{{ scope.row.opratetime }}</span>
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
  81. <template slot-scope="{row}">
  82. <!-- 跳转页面 -->
  83. <el-button class="miniSuccess" @click="jumpSee(row)">查看</el-button>
  84. <el-button class="miniSuccess" @click="jumpEdit(row)">编辑</el-button>
  85. <!-- 新增 -->
  86. <el-button v-if="row.isCreate" class="miniSuccess" :disabled="isokDisable" @click="createData(row)">保存</el-button>
  87. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  88. <!-- 编辑 -->
  89. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">设置</el-button>
  90. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  91. <!-- 编辑保存 -->
  92. <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
  93. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  94. </template>
  95. </el-table-column>
  96. </el-table>
  97. </el-form>
  98. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  99. </div>
  100. </el-tab-pane>
  101. <el-tab-pane label="图表" name="second">
  102. <div class="operation">
  103. <el-button class="success" @click="handleCreate2">新增</el-button>
  104. </div>
  105. <div class="search">
  106. <el-input v-model="table2.getdataListParm.parammaps.dname" placeholder="图表名称" style="width: 180px;" class="filter-item" clearable />
  107. <el-select v-model="table2.getdataListParm.parammaps.statue" placeholder="状态" class="filter-item" style="width: 120px;" clearable>
  108. <el-option v-for="item in statueList2" :key="item.id" :label="item.value" :value="item.id" />
  109. </el-select>
  110. <el-button class="successBorder" @click="handleSearch2">查询</el-button>
  111. <el-button class="successBorder" @click="handleRefresh2">重置</el-button>
  112. </div>
  113. <div class="table">
  114. <el-form ref="form" :rules="table2.rules" :model="table2">
  115. <el-table
  116. :key="table2.tableKey"
  117. v-loading="table2.listLoading"
  118. element-loading-text="给我一点时间"
  119. :data="table2.list"
  120. border
  121. fit
  122. highlight-current-row
  123. style="width: 100%;"
  124. :row-style="rowStyle"
  125. :cell-style="cellStyle"
  126. class="elTable table-fixed"
  127. >
  128. <!-- <el-table-column type="selection" align="center" width="50" /> -->
  129. <el-table-column label="序号" align="center" type="index" width="50px">
  130. <template slot-scope="scope">
  131. <span>{{ scope.$index + (table2.pageNum-1) * table2.pageSize + 1 }}</span>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="图表名称" min-width="200px" align="center">
  135. <template slot-scope="scope">
  136. <span v-if="scope.row.NoEdit">{{ scope.row.cname }}</span>
  137. <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" />
  138. </template>
  139. </el-table-column>
  140. <el-table-column label="图表描述" min-width="200px" align="center">
  141. <template slot-scope="scope">
  142. <span v-if="scope.row.NoEdit">{{ scope.row.display }}</span>
  143. <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" />
  144. </template>
  145. </el-table-column>
  146. <el-table-column label="状态" min-width="200px" align="center">
  147. <template slot-scope="scope">
  148. <span v-if="scope.row.NoEdit">{{ scope.row.statue == 1 ? "公开" : "私有" }}</span>
  149. <el-select v-if="scope.row.Edit" v-model="scope.row.statueid" filterable placeholder="状态" class="filter-item" style="width:95%;padding:10px 0;" @change="changeStatue">
  150. <el-option v-for="item in statueList" :key="item.id" :label="item.value" :value="item.id" />
  151. </el-select>
  152. </template>
  153. </el-table-column>
  154. <el-table-column label="创建人" min-width="200px" align="center">
  155. <template slot-scope="scope">
  156. <span>{{ scope.row.emp }}</span>
  157. </template>
  158. </el-table-column>
  159. <el-table-column label="创建时间" min-width="200px" align="center">
  160. <template slot-scope="scope">
  161. <span>{{ scope.row.opratetime }}</span>
  162. </template>
  163. </el-table-column>
  164. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
  165. <template slot-scope="{row}">
  166. <!-- 跳转页面 -->
  167. <el-button class="miniSuccess" @click="jumpSee2(row)">查看</el-button>
  168. <el-button class="miniSuccess" @click="jumpEdit2(row)">编辑</el-button>
  169. <!-- 新增 -->
  170. <el-button v-if="row.isCreate" class="miniSuccess" :disabled="isokDisable" @click="createData2(row)">保存</el-button>
  171. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel2(row)">取消</el-button>
  172. <!-- 编辑 -->
  173. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate2(row)">设置</el-button>
  174. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete2(row)">删除</el-button>
  175. <!-- 编辑保存 -->
  176. <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData2(row)">保存</el-button>
  177. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel2(row)">取消</el-button>
  178. </template>
  179. </el-table-column>
  180. </el-table>
  181. </el-form>
  182. <pagination v-show="table2.total>=0" :total="table2.total" :page.sync="table2.getdataListParm.offset" :limit.sync="table2.getdataListParm.pagecount" @pagination="getList2" />
  183. </div>
  184. </el-tab-pane>
  185. </el-tabs>
  186. <el-dialog title="新增看仪表盘" width="750px" :visible.sync="editDialogVisible">
  187. <el-form label-width="160px">
  188. <el-form-item label="仪表盘名称">
  189. <el-input v-model="dbObj.dname" size="small" style="width: 450px;" placeholder="请输入仪表盘名称" />
  190. </el-form-item>
  191. <el-form-item label="仪表盘描述">
  192. <el-input v-model="dbObj.display" type="textarea" :rows="5" size="small" style="width: 450px;" placeholder="请输入仪表盘描述" />
  193. </el-form-item>
  194. </el-form>
  195. <span slot="footer" class="dialog-footer">
  196. <el-button type="primary" size="small" @click="editDialogVisible = false">取消</el-button>
  197. <el-button type="primary" size="small" @click="handleSubmit"> 确认</el-button>
  198. </span>
  199. </el-dialog>
  200. </div>
  201. </template>
  202. <script>
  203. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  204. import Cookies from 'js-cookie'
  205. import Pagination from '@/components/Pagination'
  206. import { MessageBox } from 'element-ui'
  207. export default {
  208. name: 'BoardEchartManagement',
  209. components: { Pagination },
  210. data() {
  211. return {
  212. editDialogVisible: false,
  213. dbObj: {},
  214. // requestParams: [
  215. // { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
  216. // ],
  217. requestParams: [
  218. { name: 'getRoleAll', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  219. ],
  220. statueList: [{ id: 1, value: '公开' }, { id: 0, value: '私有' }],
  221. statueList2: [{ id: 1, value: '公开' }, { id: 0, value: '私有' }],
  222. roleList: [],
  223. table: {
  224. rules: {
  225. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  226. },
  227. getdataListParm: {
  228. name: 'getDashboardList',
  229. page: 1,
  230. offset: 1,
  231. pagecount: 10,
  232. returntype: 'Map',
  233. parammaps: {
  234. pastureid: Cookies.get('pastureid'),
  235. dname: '',
  236. statue: '',
  237. empid: Cookies.get('employeid')
  238. }
  239. },
  240. tableKey: 0,
  241. list: [],
  242. total: 0,
  243. listLoading: true,
  244. temp: {}
  245. },
  246. table2: {
  247. rules: {
  248. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  249. },
  250. getdataListParm: {
  251. name: 'getChartList',
  252. page: 1,
  253. offset: 1,
  254. pagecount: 10,
  255. returntype: 'Map',
  256. parammaps: {
  257. pastureid: Cookies.get('pastureid'),
  258. cname: '',
  259. statue: '',
  260. empid: Cookies.get('employeid')
  261. }
  262. },
  263. tableKey: 0,
  264. list: [],
  265. total: 0,
  266. listLoading: true,
  267. temp: {}
  268. },
  269. requestParam: {},
  270. isokDisable: false,
  271. selectList: [],
  272. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  273. cellStyle: { padding: 0 + 'px' },
  274. activeName: 'first'
  275. }
  276. },
  277. created() {
  278. this.getList()
  279. this.getList2()
  280. this.getDownList()
  281. },
  282. methods: {
  283. handleClick(tab, event) {
  284. console.log(tab, event)
  285. },
  286. getDownList() {
  287. GetDataByNames(this.requestParams).then(response => {
  288. console.log('下拉框数据', response.data)
  289. this.roleList = response.data.getRoleAll.list
  290. })
  291. },
  292. getList() {
  293. this.table.listLoading = true
  294. console.log(this.table.getdataListParm)
  295. GetDataByName(this.table.getdataListParm).then(response => {
  296. console.log('table数据', response.data.list)
  297. if (response.data.list !== null) {
  298. for (let i = 0; i < response.data.list.length; i++) {
  299. this.$set(response.data.list[i], 'Edit', false) // 编辑
  300. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  301. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  302. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  303. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  304. }
  305. this.table.list = response.data.list
  306. this.table.pageNum = response.data.pageNum
  307. this.table.pageSize = response.data.pageSize
  308. this.table.total = response.data.total
  309. } else {
  310. this.table.list = []
  311. }
  312. setTimeout(() => {
  313. this.table.listLoading = false
  314. }, 100)
  315. })
  316. },
  317. getList2() {
  318. this.table2.listLoading = true
  319. console.log(this.table2.getdataListParm)
  320. GetDataByName(this.table2.getdataListParm).then(response => {
  321. console.log('table2数据', response.data.list)
  322. if (response.data.list !== null) {
  323. for (let i = 0; i < response.data.list.length; i++) {
  324. this.$set(response.data.list[i], 'Edit', false) // 编辑
  325. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  326. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  327. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  328. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  329. }
  330. this.table2.list = response.data.list
  331. this.table2.pageNum = response.data.pageNum
  332. this.table2.pageSize = response.data.pageSize
  333. this.table2.total = response.data.total
  334. } else {
  335. this.table2.list = []
  336. }
  337. setTimeout(() => {
  338. this.table2.listLoading = false
  339. }, 100)
  340. })
  341. },
  342. handleEnableChange(val) {
  343. console.log('点击了是否启用', val)
  344. },
  345. handleSearch() {
  346. console.log('点击了查询')
  347. this.table.getdataListParm.offset = 1
  348. this.getList()
  349. },
  350. handleSearch2() {
  351. console.log('点击了查询')
  352. this.table2.getdataListParm.offset = 1
  353. this.getList2()
  354. },
  355. handleRefresh() {
  356. console.log('点击了重置')
  357. this.table.getdataListParm.parammaps.classname = ''
  358. this.table.getdataListParm.parammaps.parentname = ''
  359. this.table.getdataListParm.parammaps.enable = ''
  360. this.table.getdataListParm.offset = 1
  361. this.getList()
  362. },
  363. handleRefresh2() {
  364. console.log('点击了重置')
  365. this.table2.getdataListParm.parammaps.classname = ''
  366. this.table2.getdataListParm.parammaps.enable = ''
  367. this.table2.getdataListParm.offset = 1
  368. this.getList2()
  369. },
  370. // changeParent(val) {
  371. // console.log('点击了牲畜类别父类', val)
  372. // console.log(this.parentList.find(obj => obj.value == val).label)
  373. // this.table.temp.parentname = this.parentList.find(obj => obj.value == val).label
  374. // },id
  375. changeStatue(val) {
  376. console.log('点击了状态', val)
  377. // console.log(this.statueList.find(obj => obj.value == val).id)
  378. this.table.temp.statueid = val
  379. },
  380. changeStatue2(val) {
  381. console.log('点击了状态', val)
  382. // console.log(this.statueList.find(obj => obj.value == val).id)
  383. this.table2.temp.statueid = val
  384. },
  385. changeRole(val) {
  386. console.log('点击了角色', val)
  387. var arr = []
  388. this.roleList.forEach(function(i) {
  389. val.forEach(function(j) {
  390. if (i.id == j) {
  391. arr.push(i)
  392. }
  393. })
  394. })
  395. console.log('点击了角色', arr)
  396. this.table.temp.rolenames = arr
  397. },
  398. handleCreate() {
  399. this.editDialogVisible = true
  400. },
  401. handleSubmit() {
  402. var data = {
  403. name: 'insertDashboard',
  404. parammaps: {
  405. dname: this.dbObj.dname,
  406. display: this.dbObj.display,
  407. pastureid: Cookies.get('pastureid'),
  408. empid: Cookies.get('employeid'),
  409. emp: Cookies.get('employename')
  410. }
  411. }
  412. PostDataByName(data).then(res => {
  413. console.log('新增保存发送参数', data)
  414. this.$message({
  415. type: 'success',
  416. message: this.$t('common.saveSuccess')
  417. })
  418. this.editDialogVisible = false
  419. console.log('res', res)
  420. if (res.data.LastInsertId) {
  421. this.$router.push({ name: 'Addboard', params: { id: res.data.LastInsertId, isEdit: 'edit' }})
  422. }
  423. })
  424. },
  425. handleCreate2(row) {
  426. this.$router.push({ name: 'ChartPanel', params: { id: 'create', isEdit: 'edit' }})
  427. },
  428. createData(row) {
  429. console.log('点击了新增保存')
  430. this.table.temp.pastureid = Cookies.get('pastureid')
  431. this.table.temp.dname = row.dname
  432. this.table.temp.display = row.display
  433. this.table.temp.statue = row.statue
  434. this.table.temp.reportenable = row.reportenable
  435. this.table.temp.emp = row.emp
  436. this.table.temp.opratetime = row.opratetime
  437. // 仪表盘名称/状态是否为空
  438. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  439. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  440. return false
  441. } else if (this.table.temp.dname == '') {
  442. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  443. return false
  444. }
  445. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  446. if (pattern.test(this.table.temp.dname)) {
  447. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  448. return false
  449. }
  450. this.isokDisable = true
  451. setTimeout(() => {
  452. this.isokDisable = false
  453. }, 1000)
  454. this.requestParam.name = 'insertDashboard'
  455. this.requestParam.parammaps = this.table.temp
  456. PostDataByName(this.requestParam).then(response => {
  457. console.log('新增保存发送参数', this.requestParam)
  458. if (response.msg !== 'fail') {
  459. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  460. this.getList()
  461. } else {
  462. failproccess(response, this.$notify)
  463. }
  464. })
  465. },
  466. createCancel(row) {
  467. console.log('点击了新增取消')
  468. for (let i = 0; i < this.table.list.length; i++) {
  469. if (row.myId === this.table.list[i].myId) {
  470. var listIndex = this.table.list.indexOf(this.table.list[i])
  471. }
  472. if (listIndex > -1) {
  473. this.table.list.splice(listIndex, 1)
  474. return
  475. }
  476. }
  477. },
  478. jumpSee(row) {
  479. console.log('点击了查看', row)
  480. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'view' }})
  481. },
  482. jumpEdit(row) {
  483. console.log('点击了编辑', row)
  484. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'edit' }})
  485. },
  486. jumpSee2(row) {
  487. console.log('点击了查看', row)
  488. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'view' }})
  489. },
  490. jumpEdit2(row) {
  491. console.log('点击了编辑', row)
  492. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'edit' }})
  493. },
  494. handleUpdate(row) {
  495. console.log('点击了设置', row)
  496. for (let i = 0; i < this.table.list.length; i++) {
  497. if (this.table.list[i].Edit == true) {
  498. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  499. return false
  500. }
  501. }
  502. // 编辑true,不可编辑false
  503. row.Edit = true
  504. row.NoEdit = false
  505. // 新增false,编辑false,编辑保存true
  506. row.isCreate = false
  507. row.isUpdate = false
  508. row.isUpdateSave = true
  509. // console.log(row.parentid)
  510. row.statue = String(row.statue)
  511. this.table.temp.statue = row.statue
  512. this.table.temp.statueid = row.statueid
  513. this.table.temp.parentname = row.parentname
  514. },
  515. handleUpdate2(row) {
  516. console.log('点击了设置', row)
  517. for (let i = 0; i < this.table2.list.length; i++) {
  518. if (this.table2.list[i].Edit == true) {
  519. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  520. return false
  521. }
  522. }
  523. // 编辑true,不可编辑false
  524. row.Edit = true
  525. row.NoEdit = false
  526. // 新增false,编辑false,编辑保存true
  527. row.isCreate = false
  528. row.isUpdate = false
  529. row.isUpdateSave = true
  530. // console.log(row.parentid)
  531. row.statue = String(row.statue)
  532. this.table2.temp.statue = row.statue
  533. this.table2.temp.statueid = row.statueid
  534. },
  535. updateData(row) {
  536. console.log('点击了编辑保存')
  537. this.table.temp.pastureid = Cookies.get('pastureid')
  538. this.table.temp.dname = row.dname
  539. this.table.temp.display = row.display
  540. this.table.temp.reportenable = row.reportenable
  541. this.table.temp.emp = row.emp
  542. this.table.temp.opratetime = row.opratetime
  543. this.table.temp.id = row.id
  544. this.table.temp.statue = row.statueid
  545. // 仪表盘名称/状态是否为空
  546. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  547. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  548. return false
  549. } else if (this.table.temp.dname == '') {
  550. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  551. return false
  552. }
  553. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  554. if (pattern.test(this.table.temp.dname)) {
  555. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  556. return false
  557. }
  558. this.isokDisable = true
  559. setTimeout(() => {
  560. this.isokDisable = false
  561. }, 1000)
  562. console.log(this.table.temp)
  563. var send_data3 = {
  564. 'common': { 'returnmap': '0' },
  565. 'data': [
  566. {
  567. 'name': 'updateDashboard',
  568. 'type': 'e',
  569. 'parammaps': this.table.temp
  570. },
  571. {
  572. 'name': 'deleteDrole',
  573. 'type': 'e',
  574. 'parammaps': {
  575. 'id': row.id,
  576. 'pastureid': Cookies.get('pastureid')
  577. }
  578. },
  579. {
  580. 'name': 'insertSpotList',
  581. 'resultmaps': {
  582. 'list': this.table.temp.rolenames
  583. },
  584. 'children': [
  585. {
  586. 'name': 'insertDrole',
  587. 'type': 'e',
  588. 'parammaps':
  589. {
  590. 'id': row.id,
  591. 'pastureid': Cookies.get('pastureid'),
  592. 'roleid': '@insertSpotList.id'
  593. }
  594. }
  595. ]
  596. }
  597. ]
  598. }
  599. ExecDataByConfig(send_data3).then(response => {
  600. if (response.msg !== 'fail') {
  601. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  602. this.getList()
  603. } else {
  604. failproccess(response, this.$notify)
  605. }
  606. })
  607. },
  608. updateData2(row) {
  609. console.log('点击了编辑保存')
  610. this.table2.temp.pastureid = Cookies.get('pastureid')
  611. this.table2.temp.cname = row.cname
  612. this.table2.temp.display = row.display
  613. this.table2.temp.emp = row.emp
  614. this.table2.temp.opratetime = row.opratetime
  615. this.table2.temp.id = row.id
  616. this.table2.temp.statue = row.statueid
  617. // 仪表盘名称/状态是否为空
  618. if (this.table2.temp.dname == '' && this.table.temp.statue == '') {
  619. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  620. return false
  621. } else if (this.table2.temp.dname == '') {
  622. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  623. return false
  624. }
  625. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  626. if (pattern.test(this.table2.temp.dname)) {
  627. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  628. return false
  629. }
  630. this.isokDisable = true
  631. setTimeout(() => {
  632. this.isokDisable = false
  633. }, 1000)
  634. console.log(this.table2.temp)
  635. var send_data3 = {
  636. 'name': 'updateChart',
  637. 'parammaps': this.table2.temp
  638. }
  639. PostDataByName(send_data3).then(response => {
  640. console.log('新增保存发送参数', send_data3)
  641. if (response.msg !== 'fail') {
  642. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  643. this.getList2()
  644. } else {
  645. failproccess(response, this.$notify)
  646. }
  647. })
  648. },
  649. updateCancel(row) {
  650. console.log('点击了编辑取消')
  651. // 编辑false,不可编辑true
  652. row.Edit = false
  653. row.NoEdit = true
  654. // 新增false,编辑true,编辑保存false
  655. row.isCreate = false
  656. row.isUpdate = true
  657. row.isUpdateSave = false
  658. },
  659. updateCancel2(row) {
  660. console.log('点击了编辑取消')
  661. // 编辑false,不可编辑true
  662. row.Edit = false
  663. row.NoEdit = true
  664. // 新增false,编辑true,编辑保存false
  665. row.isCreate = false
  666. row.isUpdate = true
  667. row.isUpdateSave = false
  668. },
  669. handleRowDelete(row) {
  670. console.log('点击了行内删除')
  671. MessageBox.confirm('是否确认删除此信息?', {
  672. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  673. }).then(() => {
  674. this.requestParam.name = 'deleteDashboard'
  675. this.requestParam.parammaps = {}
  676. this.requestParam.parammaps.pastureid = row.pastureid
  677. this.requestParam.parammaps.id = row.id
  678. PostDataByName(this.requestParam).then(response => {
  679. if (response.msg === 'fail') {
  680. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  681. } else {
  682. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  683. this.getList()
  684. }
  685. })
  686. }).catch(() => {
  687. this.$message({ type: 'info', message: '已取消删除' })
  688. })
  689. },
  690. handleRowDelete2(row) {
  691. console.log('点击了行内删除')
  692. MessageBox.confirm('是否确认删除此信息?', {
  693. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  694. }).then(() => {
  695. this.requestParam.name = 'deleteChart'
  696. this.requestParam.parammaps = {}
  697. this.requestParam.parammaps.pastureid = row.pastureid
  698. this.requestParam.parammaps.id = row.id
  699. PostDataByName(this.requestParam).then(response => {
  700. if (response.msg === 'fail') {
  701. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  702. } else {
  703. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  704. this.getList()
  705. }
  706. })
  707. }).catch(() => {
  708. this.$message({ type: 'info', message: '已取消删除' })
  709. })
  710. }
  711. }
  712. }
  713. </script>
  714. <style lang="scss" scoped>
  715. .search {
  716. margin-top: 10px;
  717. }
  718. .table {
  719. margin-top: 10px;
  720. }
  721. </style>