88e64647d04cf5d857e78371e2f793f9c2a10fcf.svn-base 31 KB

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