49cd77a10fd7786dcbb418fa68a347714dfcdc63.svn-base 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  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. Cookies.set('AddboardIsEdit', 'create')
  418. Cookies.set('AddboardIsEditId', res.data.LastInsertId)
  419. }
  420. })
  421. },
  422. createData(row) {
  423. console.log('点击了新增保存')
  424. this.table.temp.pastureid = Cookies.get('pastureid')
  425. this.table.temp.dname = row.dname
  426. this.table.temp.display = row.display
  427. this.table.temp.statue = row.statue
  428. this.table.temp.reportenable = row.reportenable
  429. this.table.temp.emp = row.emp
  430. this.table.temp.opratetime = row.opratetime
  431. // 仪表盘名称/状态是否为空
  432. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  433. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  434. return false
  435. } else if (this.table.temp.dname == '') {
  436. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  437. return false
  438. }
  439. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  440. if (pattern.test(this.table.temp.dname)) {
  441. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  442. return false
  443. }
  444. this.isokDisable = true
  445. setTimeout(() => {
  446. this.isokDisable = false
  447. }, 1000)
  448. this.requestParam.name = 'insertDashboard'
  449. this.requestParam.parammaps = this.table.temp
  450. PostDataByName(this.requestParam).then(response => {
  451. console.log('新增保存发送参数', this.requestParam)
  452. if (response.msg !== 'fail') {
  453. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  454. this.getList()
  455. } else {
  456. failproccess(response, this.$notify)
  457. }
  458. })
  459. },
  460. createCancel(row) {
  461. console.log('点击了新增取消')
  462. for (let i = 0; i < this.table.list.length; i++) {
  463. if (row.myId === this.table.list[i].myId) {
  464. var listIndex = this.table.list.indexOf(this.table.list[i])
  465. }
  466. if (listIndex > -1) {
  467. this.table.list.splice(listIndex, 1)
  468. return
  469. }
  470. }
  471. },
  472. handleCreate2(row) {
  473. this.$router.push({ name: 'ChartPanel', params: { id: 'create', isEdit: 'edit' } })
  474. Cookies.set('ChartPanelIsEdit', 'edit')
  475. Cookies.set('ChartPanelIsEditId', 'create')
  476. },
  477. jumpSee(row) {
  478. console.log('点击了查看', row)
  479. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'view' } })
  480. Cookies.set('AddboardIsEdit', 'view')
  481. Cookies.set('AddboardIsEditId', row.id)
  482. },
  483. jumpEdit(row) {
  484. console.log('点击了编辑', row)
  485. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'edit' } })
  486. Cookies.set('AddboardIsEdit', 'edit')
  487. Cookies.set('AddboardIsEditId', row.id)
  488. },
  489. jumpSee2(row) {
  490. console.log('点击了查看', row)
  491. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'view' } })
  492. Cookies.set('ChartPanelIsEdit', 'view')
  493. Cookies.set('ChartPanelIsEditId', row.id)
  494. },
  495. jumpEdit2(row) {
  496. console.log('点击了编辑', row)
  497. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'edit' } })
  498. Cookies.set('ChartPanelIsEdit', 'edit')
  499. Cookies.set('ChartPanelIsEditId', row.id)
  500. },
  501. handleUpdate(row) {
  502. console.log('点击了设置', row)
  503. for (let i = 0; i < this.table.list.length; i++) {
  504. if (this.table.list[i].Edit == true) {
  505. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  506. return false
  507. }
  508. }
  509. // 编辑true,不可编辑false
  510. row.Edit = true
  511. row.NoEdit = false
  512. // 新增false,编辑false,编辑保存true
  513. row.isCreate = false
  514. row.isUpdate = false
  515. row.isUpdateSave = true
  516. // console.log(row.parentid)
  517. row.statue = String(row.statue)
  518. console.log("row.statue ", row.statue)
  519. this.table.temp.statue = row.statue
  520. this.table.temp.statueid = row.statueid
  521. this.table.temp.parentname = row.parentname
  522. },
  523. handleUpdate2(row) {
  524. console.log('点击了设置', row)
  525. for (let i = 0; i < this.table2.list.length; i++) {
  526. if (this.table2.list[i].Edit == true) {
  527. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  528. return false
  529. }
  530. }
  531. // 编辑true,不可编辑false
  532. row.Edit = true
  533. row.NoEdit = false
  534. // 新增false,编辑false,编辑保存true
  535. row.isCreate = false
  536. row.isUpdate = false
  537. row.isUpdateSave = true
  538. // console.log(row.parentid)
  539. row.statue = String(row.statue)
  540. this.table2.temp.statue = row.statue
  541. this.table2.temp.statueid = row.statueid
  542. },
  543. updateData(row) {
  544. console.log('点击了编辑保存')
  545. this.table.temp.pastureid = Cookies.get('pastureid')
  546. this.table.temp.dname = row.dname
  547. this.table.temp.display = row.display
  548. this.table.temp.reportenable = row.reportenable
  549. this.table.temp.emp = row.emp
  550. this.table.temp.opratetime = row.opratetime
  551. this.table.temp.id = row.id
  552. this.table.temp.statue = row.statue
  553. this.table.temp.rolenamesId = row.rolenamesId
  554. console.log(this.table.temp.rolenamesId)
  555. var rolenamesIdArr = []
  556. this.table.temp.rolenamesId.forEach(function (i, j) {
  557. rolenamesIdArr.push({ "id": i })
  558. })
  559. // 仪表盘名称/状态是否为空
  560. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  561. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  562. return false
  563. } else if (this.table.temp.dname == '') {
  564. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  565. return false
  566. }
  567. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  568. if (pattern.test(this.table.temp.dname)) {
  569. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  570. return false
  571. }
  572. this.isokDisable = true
  573. setTimeout(() => {
  574. this.isokDisable = false
  575. }, 1000)
  576. console.log(this.table.temp)
  577. var send_data3 = {
  578. 'common': { 'returnmap': '0' },
  579. 'data': [
  580. {
  581. 'name': 'updateDashboard',
  582. 'type': 'e',
  583. 'parammaps': this.table.temp
  584. },
  585. {
  586. 'name': 'deleteDrole',
  587. 'type': 'e',
  588. 'parammaps': {
  589. 'id': row.id,
  590. 'pastureid': Cookies.get('pastureid')
  591. }
  592. },
  593. {
  594. 'name': 'insertSpotList',
  595. 'resultmaps': {
  596. 'list': rolenamesIdArr
  597. },
  598. 'children': [
  599. {
  600. 'name': 'insertDrole',
  601. 'type': 'e',
  602. 'parammaps':
  603. {
  604. 'id': row.id,
  605. 'pastureid': Cookies.get('pastureid'),
  606. 'roleid': '@insertSpotList.id'
  607. }
  608. }
  609. ]
  610. }
  611. ]
  612. }
  613. ExecDataByConfig(send_data3).then(response => {
  614. if (response.msg !== 'fail') {
  615. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  616. this.getList()
  617. } else {
  618. failproccess(response, this.$notify)
  619. }
  620. })
  621. },
  622. updateData2(row) {
  623. console.log('点击了编辑保存')
  624. this.table2.temp.pastureid = Cookies.get('pastureid')
  625. this.table2.temp.cname = row.cname
  626. this.table2.temp.display = row.display
  627. this.table2.temp.emp = row.emp
  628. this.table2.temp.opratetime = row.opratetime
  629. this.table2.temp.id = row.id
  630. this.table2.temp.statue = row.statue
  631. // 仪表盘名称/状态是否为空
  632. if (this.table2.temp.dname == '' && this.table.temp.statue == '') {
  633. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  634. return false
  635. } else if (this.table2.temp.dname == '') {
  636. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  637. return false
  638. }
  639. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  640. if (pattern.test(this.table2.temp.dname)) {
  641. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  642. return false
  643. }
  644. this.isokDisable = true
  645. setTimeout(() => {
  646. this.isokDisable = false
  647. }, 1000)
  648. console.log(this.table2.temp)
  649. var send_data3 = {
  650. 'name': 'updateChart',
  651. 'parammaps': this.table2.temp
  652. }
  653. PostDataByName(send_data3).then(response => {
  654. console.log('新增保存发送参数', send_data3)
  655. if (response.msg !== 'fail') {
  656. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  657. this.getList2()
  658. } else {
  659. failproccess(response, this.$notify)
  660. }
  661. })
  662. },
  663. updateCancel(row) {
  664. console.log('点击了编辑取消')
  665. // 编辑false,不可编辑true
  666. row.Edit = false
  667. row.NoEdit = true
  668. // 新增false,编辑true,编辑保存false
  669. row.isCreate = false
  670. row.isUpdate = true
  671. row.isUpdateSave = false
  672. },
  673. updateCancel2(row) {
  674. console.log('点击了编辑取消')
  675. // 编辑false,不可编辑true
  676. row.Edit = false
  677. row.NoEdit = true
  678. // 新增false,编辑true,编辑保存false
  679. row.isCreate = false
  680. row.isUpdate = true
  681. row.isUpdateSave = false
  682. },
  683. handleRowDelete(row) {
  684. console.log('点击了行内删除')
  685. MessageBox.confirm('是否确认删除此信息?', {
  686. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  687. }).then(() => {
  688. this.requestParam.name = 'deleteDashboard'
  689. this.requestParam.parammaps = {}
  690. this.requestParam.parammaps.pastureid = row.pastureid
  691. this.requestParam.parammaps.id = row.id
  692. PostDataByName(this.requestParam).then(response => {
  693. if (response.msg === 'fail') {
  694. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  695. } else {
  696. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  697. this.getList()
  698. }
  699. })
  700. }).catch(() => {
  701. this.$message({ type: 'info', message: '已取消删除' })
  702. })
  703. },
  704. handleRowDelete2(row) {
  705. console.log('点击了行内删除')
  706. MessageBox.confirm('是否确认删除此信息?', {
  707. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  708. }).then(() => {
  709. this.requestParam.name = 'deleteChart'
  710. this.requestParam.parammaps = {}
  711. this.requestParam.parammaps.pastureid = row.pastureid
  712. this.requestParam.parammaps.id = row.id
  713. PostDataByName(this.requestParam).then(response => {
  714. if (response.msg === 'fail') {
  715. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  716. } else {
  717. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  718. this.getList2()
  719. }
  720. })
  721. }).catch(() => {
  722. this.$message({ type: 'info', message: '已取消删除' })
  723. })
  724. }
  725. }
  726. }
  727. </script>
  728. <style lang="scss" scoped>
  729. .search {
  730. margin-top: 10px;
  731. }
  732. .table {
  733. margin-top: 10px;
  734. }
  735. </style>