f46fd7c5bf784502cd3186c7f2d09538e966de0d.svn-base 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  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 enableList" :key="item.id" :label="item.name" :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. @selection-change="handleSelectionChange"
  31. >
  32. <!-- <el-table-column type="selection" align="center" width="50" /> -->
  33. <el-table-column label="序号" align="center" type="index" width="50px">
  34. <template slot-scope="scope">
  35. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="仪表盘名称" min-width="200px" align="center">
  39. <template slot-scope="scope">
  40. <span v-if="scope.row.NoEdit">{{ scope.row.dname }}</span>
  41. <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" />
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="仪表盘描述" min-width="200px" align="center">
  45. <template slot-scope="scope">
  46. <span v-if="scope.row.NoEdit">{{ scope.row.display }}</span>
  47. <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" />
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="状态" min-width="200px" align="center">
  51. <template slot-scope="scope">
  52. <span v-if="scope.row.NoEdit">{{ scope.row.statue == 1 ? "公开" : "私有" }}</span>
  53. <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">
  54. <el-option v-for="item in statueList" :key="item.id" :label="item.id" :value="item.value" />
  55. </el-select>
  56. </template>
  57. </el-table-column>
  58. <!-- <el-table-column label="分发角色" min-width="200px" align="center">
  59. <template slot-scope="scope">
  60. <span v-if="scope.row.NoEdit">{{ scope.row.parentname }}</span>
  61. <el-select v-if="scope.row.Edit" v-model="scope.row.parentid" multiple filterable placeholder="分发角色" class="filter-item" style="width:95%;padding:10px 0;" @change="changeParent">
  62. <el-option v-for="item in parentList" :key="item.value" :label="item.label" :value="item.value" />
  63. </el-select>
  64. </template>
  65. </el-table-column> -->
  66. <el-table-column label="分发角色" min-width="200px" align="center">
  67. <template slot-scope="scope">
  68. <span v-if="scope.row.NoEdit">{{ scope.row.rolenames }}</span>
  69. <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">
  70. <el-option v-for="item in roleList" :key="item.id" :label="item.rolename" :value="item.id" />
  71. </el-select>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="报表显示" min-width="110px" align="center">
  75. <template slot-scope="scope">
  76. <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)" />
  77. </template>
  78. </el-table-column>
  79. <el-table-column label="创建人" min-width="200px" align="center">
  80. <template slot-scope="scope">
  81. <span>{{ scope.row.emp }}</span>
  82. </template>
  83. </el-table-column>
  84. <el-table-column label="创建时间" min-width="200px" align="center">
  85. <template slot-scope="scope">
  86. <span>{{ scope.row.oprateTime }}</span>
  87. </template>
  88. </el-table-column>
  89. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
  90. <template slot-scope="{row}">
  91. <!-- 跳转页面 -->
  92. <el-button class="miniSuccess" @click="jumpSee(row)">查看</el-button>
  93. <el-button class="miniSuccess" @click="jumpEdit(row)">编辑</el-button>
  94. <!-- 新增 -->
  95. <el-button v-if="row.isCreate" class="miniSuccess" :disabled="isokDisable" @click="createData(row)">保存</el-button>
  96. <el-button v-if="row.isCreate" class="minCancel" @click="createCancel(row)">取消</el-button>
  97. <!-- 编辑 -->
  98. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">设置</el-button>
  99. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  100. <!-- 编辑保存 -->
  101. <el-button v-if="row.isUpdateSave" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
  102. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  103. </template>
  104. </el-table-column>
  105. </el-table>
  106. </el-form>
  107. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  108. </div>
  109. </el-tab-pane>
  110. <el-tab-pane label="图表" name="second">图表</el-tab-pane>
  111. </el-tabs>
  112. </div>
  113. </template>
  114. <script>
  115. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig } from '@/api/common'
  116. import Cookies from 'js-cookie'
  117. import Pagination from '@/components/Pagination'
  118. import { MessageBox } from 'element-ui'
  119. export default {
  120. name: 'BoardEchartManagement',
  121. components: { Pagination },
  122. data() {
  123. return {
  124. // requestParams: [
  125. // { name: 'getDictByName', offset: 0, pagecount: 0, params: ['牲畜父类'] }
  126. // ],
  127. requestParams: [
  128. { name: 'getRoleAll', offset: 0, pagecount: 0, parammaps: { pastureid: Cookies.get('pastureid') }}
  129. ],
  130. enableList: [{ id: 1, name: '公开' }, { id: 0, name: '私有' }],
  131. statueList: [{ id: 1, value: '公开' }, { id: 0, value: '私有' }],
  132. roleList: [],
  133. table: {
  134. rules: {
  135. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  136. },
  137. getdataListParm: {
  138. name: 'getDashboardList',
  139. page: 1,
  140. offset: 1,
  141. pagecount: 10,
  142. returntype: 'Map',
  143. parammaps: {
  144. pastureid: Cookies.get('pastureid'),
  145. dname: '',
  146. statue: ''
  147. }
  148. },
  149. tableKey: 0,
  150. list: [],
  151. total: 0,
  152. listLoading: true,
  153. temp: {}
  154. },
  155. requestParam: {},
  156. isokDisable: false,
  157. selectList: [],
  158. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  159. cellStyle: { padding: 0 + 'px' },
  160. activeName: 'first'
  161. }
  162. },
  163. created() {
  164. this.getList()
  165. this.getDownList()
  166. },
  167. methods: {
  168. handleClick(tab, event) {
  169. console.log(tab, event)
  170. },
  171. getDownList() {
  172. GetDataByNames(this.requestParams).then(response => {
  173. console.log('下拉框数据', response.data)
  174. this.roleList = response.data.getRoleAll.list
  175. })
  176. },
  177. getList() {
  178. this.table.listLoading = true
  179. console.log(this.table.getdataListParm)
  180. GetDataByName(this.table.getdataListParm).then(response => {
  181. console.log('table数据', response.data.list)
  182. if (response.data.list !== null) {
  183. for (let i = 0; i < response.data.list.length; i++) {
  184. this.$set(response.data.list[i], 'Edit', false) // 编辑
  185. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  186. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  187. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  188. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  189. }
  190. this.table.list = response.data.list
  191. this.table.pageNum = response.data.pageNum
  192. this.table.pageSize = response.data.pageSize
  193. this.table.total = response.data.total
  194. } else {
  195. this.table.list = []
  196. }
  197. setTimeout(() => {
  198. this.table.listLoading = false
  199. }, 100)
  200. })
  201. },
  202. handleEnableChange(val) {
  203. console.log('点击了是否启用', val)
  204. },
  205. handleSearch() {
  206. console.log('点击了查询')
  207. this.table.getdataListParm.offset = 1
  208. this.getList()
  209. },
  210. handleRefresh() {
  211. console.log('点击了重置')
  212. this.table.getdataListParm.parammaps.classname = ''
  213. this.table.getdataListParm.parammaps.parentname = ''
  214. this.table.getdataListParm.parammaps.enable = ''
  215. this.table.getdataListParm.offset = 1
  216. this.getList()
  217. },
  218. // changeParent(val) {
  219. // console.log('点击了牲畜类别父类', val)
  220. // console.log(this.parentList.find(obj => obj.value == val).label)
  221. // this.table.temp.parentname = this.parentList.find(obj => obj.value == val).label
  222. // },
  223. changeStatue(val) {
  224. console.log('点击了状态', val)
  225. console.log(this.statueList.find(obj => obj.value == val).label)
  226. this.table.temp.statue = this.statueList.find(obj => obj.value == val).label
  227. },
  228. changeRole(val) {
  229. console.log('点击了角色', val)
  230. console.log(this.roleList.find(obj => obj.value == val).label)
  231. this.table.temp.role = this.roleList.find(obj => obj.value == val).label
  232. },
  233. handleCreate() {
  234. console.log('点击了新增')
  235. // 编辑true/不可编辑false
  236. // 新增操true,编辑false,编辑保存false
  237. for (let i = 0; i < this.table.list.length; i++) {
  238. if (this.table.list[i].Edit == true) {
  239. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  240. return false
  241. }
  242. }
  243. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'dname': '', 'display': '', 'reportenable': 0, 'emp': '', 'oprateTime': '' })
  244. },
  245. createData(row) {
  246. console.log('点击了新增保存')
  247. this.table.temp.pastureid = Cookies.get('pastureid')
  248. this.table.temp.dname = row.dname
  249. this.table.temp.display = row.display
  250. this.table.temp.statue = row.statue
  251. this.table.temp.reportenable = row.reportenable
  252. this.table.temp.emp = row.emp
  253. this.table.temp.oprateTime = row.oprateTime
  254. // 仪表盘名称/状态是否为空
  255. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  256. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  257. return false
  258. } else if (this.table.temp.dname == '') {
  259. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  260. return false
  261. }
  262. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  263. if (pattern.test(this.table.temp.dname)) {
  264. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  265. return false
  266. }
  267. this.isokDisable = true
  268. setTimeout(() => {
  269. this.isokDisable = false
  270. }, 1000)
  271. this.requestParam.name = 'insertDashboard'
  272. this.requestParam.parammaps = this.table.temp
  273. PostDataByName(this.requestParam).then(response => {
  274. console.log('新增保存发送参数', this.requestParam)
  275. if (response.msg !== 'fail') {
  276. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  277. this.getList()
  278. } else {
  279. failproccess(response, this.$notify)
  280. }
  281. })
  282. },
  283. createCancel(row) {
  284. console.log('点击了新增取消')
  285. for (let i = 0; i < this.table.list.length; i++) {
  286. if (row.myId === this.table.list[i].myId) {
  287. var listIndex = this.table.list.indexOf(this.table.list[i])
  288. }
  289. if (listIndex > -1) {
  290. this.table.list.splice(listIndex, 1)
  291. return
  292. }
  293. }
  294. },
  295. jumpSee(row) {
  296. console.log('点击了查看', row)
  297. this.$router.push({ path: '/customboard/Addboard', query: { providerName: row.providerName }})
  298. },
  299. jumpEdit(row) {
  300. console.log('点击了编辑', row)
  301. this.$router.push({ path: '/customboard/Addboard', query: { providerName: row.providerName }})
  302. },
  303. handleUpdate(row) {
  304. console.log('点击了设置', row)
  305. for (let i = 0; i < this.table.list.length; i++) {
  306. if (this.table.list[i].Edit == true) {
  307. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  308. return false
  309. }
  310. }
  311. // 编辑true,不可编辑false
  312. row.Edit = true
  313. row.NoEdit = false
  314. // 新增false,编辑false,编辑保存true
  315. row.isCreate = false
  316. row.isUpdate = false
  317. row.isUpdateSave = true
  318. // console.log(row.parentid)
  319. row.statue = String(row.statue)
  320. this.table.temp.statue = row.statue
  321. this.table.temp.parentname = row.parentname
  322. },
  323. updateData(row) {
  324. console.log('点击了编辑保存')
  325. this.table.temp.pastureid = Cookies.get('pastureid')
  326. this.table.temp.classcode = row.classcode
  327. this.table.temp.classname = row.classname
  328. this.table.temp.statue = row.statue
  329. this.table.temp.enable = row.enable
  330. this.table.temp.id = row.id
  331. // 仪表盘名称/状态是否为空
  332. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  333. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  334. return false
  335. } else if (this.table.temp.dname == '') {
  336. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  337. return false
  338. }
  339. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  340. if (pattern.test(this.table.temp.dname)) {
  341. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  342. return false
  343. }
  344. this.isokDisable = true
  345. setTimeout(() => {
  346. this.isokDisable = false
  347. }, 1000)
  348. console.log(this.table.temp)
  349. var send_data3 = {
  350. 'common': { 'returnmap': '0' },
  351. 'data': [
  352. {
  353. 'name': 'updateDashboard',
  354. 'type': 'e',
  355. 'parammaps': this.table.temp
  356. },
  357. {
  358. 'name': 'deleteDrole',
  359. 'type': 'e',
  360. 'parammaps': {
  361. 'id': '1',
  362. 'pastureid': '1'
  363. }
  364. },
  365. {
  366. 'name': 'insertSpotList',
  367. 'resultmaps': {
  368. 'list': '角色的LIST'
  369. },
  370. 'children': [
  371. {
  372. 'name': 'insertDrole',
  373. 'type': 'e',
  374. 'parammaps':
  375. {
  376. 'id': '1',
  377. 'pastureId': '2',
  378. 'roleid': '@insertSpotList.id'
  379. }
  380. }
  381. ]
  382. }
  383. ]
  384. }
  385. this.requestParam.common = { 'returnmap': '0' }
  386. this.requestParam.data = []
  387. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  388. this.requestParam.data[0].children = []
  389. this.requestParam.data[0].children[0] = { 'name': 'deleteTMR', 'type': 'e', 'parammaps': {
  390. id: '@insertSpotList.id',
  391. pastureid: '@insertSpotList.pastureid'
  392. }}
  393. // ExecDataByConfig(send_data).then(response => {
  394. // if (response.msg !== 'fail') {
  395. // this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  396. // this.getList()
  397. // } else {
  398. // failproccess(response, this.$notify)
  399. // }
  400. // })
  401. },
  402. updateCancel(row) {
  403. console.log('点击了编辑取消')
  404. // 编辑false,不可编辑true
  405. row.Edit = false
  406. row.NoEdit = true
  407. // 新增false,编辑true,编辑保存false
  408. row.isCreate = false
  409. row.isUpdate = true
  410. row.isUpdateSave = false
  411. },
  412. handleRowDelete(row) {
  413. console.log('点击了行内删除')
  414. MessageBox.confirm('是否确认删除此信息?', {
  415. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  416. }).then(() => {
  417. this.requestParam.name = 'deleteCowclass'
  418. this.requestParam.parammaps = {}
  419. this.requestParam.parammaps.pastureid = row.pastureid
  420. this.requestParam.parammaps.id = row.id
  421. PostDataByName(this.requestParam).then(response => {
  422. if (response.msg === 'fail') {
  423. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  424. } else {
  425. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  426. this.getList()
  427. }
  428. })
  429. }).catch(() => {
  430. this.$message({ type: 'info', message: '已取消删除' })
  431. })
  432. },
  433. handleSelectionChange(val) {
  434. console.log('勾选数据', val)
  435. this.selectList = val
  436. }
  437. }
  438. }
  439. </script>
  440. <style lang="scss" scoped>
  441. .search {
  442. margin-top: 10px;
  443. }
  444. .table {
  445. margin-top: 10px;
  446. }
  447. </style>