115a511090f173687491cf5266619b94b641dd24.svn-base 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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. rolenamesIdTempArr: [],
  203. table: {
  204. rules: {
  205. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  206. },
  207. getdataListParm: {
  208. name: 'getDashboardList',
  209. page: 1,
  210. offset: 1,
  211. pagecount: 10,
  212. returntype: 'Map',
  213. parammaps: {
  214. pastureid: Cookies.get('pastureid'),
  215. dname: '',
  216. statue: '',
  217. empid: Cookies.get('employeid')
  218. }
  219. },
  220. tableKey: 0,
  221. list: [],
  222. total: 0,
  223. listLoading: true,
  224. temp: {}
  225. },
  226. table2: {
  227. rules: {
  228. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  229. },
  230. getdataListParm: {
  231. name: 'getChartList',
  232. page: 1,
  233. offset: 1,
  234. pagecount: 10,
  235. returntype: 'Map',
  236. parammaps: {
  237. pastureid: Cookies.get('pastureid'),
  238. cname: '',
  239. statue: '',
  240. empid: Cookies.get('employeid')
  241. }
  242. },
  243. tableKey: 0,
  244. list: [],
  245. total: 0,
  246. listLoading: true,
  247. temp: {}
  248. },
  249. requestParam: {},
  250. isokDisable: false,
  251. selectList: [],
  252. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  253. cellStyle: { padding: 0 + 'px' },
  254. activeName: 'first'
  255. }
  256. },
  257. created() {
  258. this.getList()
  259. this.getList2()
  260. this.getDownList()
  261. if (this.$route.params.tab == 'second') {
  262. this.activeName = 'second'
  263. } else {
  264. this.activeName = 'first'
  265. }
  266. },
  267. methods: {
  268. handleClick(tab, event) {
  269. console.log(tab, event)
  270. },
  271. getDownList() {
  272. GetDataByNames(this.requestParams).then(response => {
  273. console.log('下拉框数据', response.data)
  274. this.roleList = response.data.getRoleAll.list
  275. })
  276. },
  277. getList() {
  278. this.table.listLoading = true
  279. console.log(this.table.getdataListParm)
  280. GetDataByName(this.table.getdataListParm).then(response => {
  281. console.log('table数据', response.data.list)
  282. if (response.data.list !== null) {
  283. for (let i = 0; i < response.data.list.length; i++) {
  284. this.$set(response.data.list[i], 'Edit', false) // 编辑
  285. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  286. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  287. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  288. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  289. }
  290. var arr = response.data.list
  291. arr.map(function (i, j) {
  292. if (i.roleids) {
  293. return i.rolenamesId = i.roleids.split(",")
  294. } else {
  295. return i.rolenamesId = []
  296. }
  297. })
  298. arr.map(function (i, j) {
  299. if (i.roleids) {
  300. return i.rolenamesId2B = i.roleids.split(",")
  301. } else {
  302. return i.rolenamesId2B = []
  303. }
  304. })
  305. this.table.list = arr
  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.cname = ''
  358. this.table.getdataListParm.parammaps.dname = ''
  359. this.table.getdataListParm.parammaps.statue = ''
  360. this.table.getdataListParm.offset = 1
  361. this.getList()
  362. },
  363. handleRefresh2() {
  364. console.log('点击了重置')
  365. this.table2.getdataListParm.parammaps.cname = ''
  366. this.table2.getdataListParm.parammaps.dname = ''
  367. this.table2.getdataListParm.parammaps.statue = ''
  368. this.table2.getdataListParm.offset = 1
  369. this.getList2()
  370. },
  371. // changeParent(val) {
  372. // console.log('点击了牲畜类别父类', val)
  373. // console.log(this.parentList.find(obj => obj.value == val).label)
  374. // this.table.temp.parentname = this.parentList.find(obj => obj.value == val).label
  375. // },id
  376. changeStatue(val) {
  377. console.log('点击了状态', val)
  378. // console.log(this.statueList.find(obj => obj.value == val).id)
  379. this.table.temp.statueid = val
  380. this.table.temp.statue = val
  381. },
  382. changeStatue2(val) {
  383. console.log('点击了状态', val)
  384. // console.log(this.statueList.find(obj => obj.value == val).id)
  385. this.table2.temp.statueid = val
  386. this.table2.temp.statue = val
  387. },
  388. changeRole(val) {
  389. console.log('点击了角色', val)
  390. console.log('this.table.list', this.table.list)
  391. var arr = []
  392. this.roleList.forEach(function (i) {
  393. val.forEach(function (j) {
  394. if (i.id == j) {
  395. arr.push(i)
  396. }
  397. })
  398. })
  399. console.log('点击了角色', arr)
  400. this.table.temp.rolenamesId = arr
  401. this.rolenamesIdTempArr = arr
  402. },
  403. handleCreate() {
  404. this.editDialogVisible = true
  405. },
  406. handleSubmit() {
  407. var data = {
  408. name: 'insertDashboard',
  409. parammaps: {
  410. dname: this.dbObj.dname,
  411. display: this.dbObj.display,
  412. pastureid: Cookies.get('pastureid'),
  413. empid: Cookies.get('employeid'),
  414. emp: Cookies.get('employename')
  415. }
  416. }
  417. PostDataByName(data).then(res => {
  418. console.log('新增保存发送参数', data)
  419. this.$message({
  420. type: 'success',
  421. message: this.$t('common.saveSuccess')
  422. })
  423. this.editDialogVisible = false
  424. console.log('res', res)
  425. if (res.data.LastInsertId) {
  426. this.$router.push({ name: 'Addboard', params: { id: res.data.LastInsertId, isEdit: 'create' } })
  427. Cookies.set('AddboardIsEdit', 'create')
  428. Cookies.set('AddboardIsEditId', res.data.LastInsertId)
  429. localStorage.setItem("AddboardIsEditId", res.data.LastInsertId)
  430. }
  431. })
  432. },
  433. createData(row) {
  434. console.log('点击了新增保存')
  435. this.table.temp.pastureid = Cookies.get('pastureid')
  436. this.table.temp.dname = row.dname
  437. this.table.temp.display = row.display
  438. this.table.temp.statue = row.statue
  439. this.table.temp.reportenable = row.reportenable
  440. this.table.temp.emp = row.emp
  441. this.table.temp.opratetime = row.opratetime
  442. // 仪表盘名称/状态是否为空
  443. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  444. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  445. return false
  446. } else if (this.table.temp.dname == '') {
  447. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  448. return false
  449. }
  450. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  451. if (pattern.test(this.table.temp.dname)) {
  452. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  453. return false
  454. }
  455. this.isokDisable = true
  456. setTimeout(() => {
  457. this.isokDisable = false
  458. }, 1000)
  459. this.requestParam.name = 'insertDashboard'
  460. this.requestParam.parammaps = this.table.temp
  461. PostDataByName(this.requestParam).then(response => {
  462. console.log('新增保存发送参数', this.requestParam)
  463. if (response.msg !== 'fail') {
  464. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  465. this.getList()
  466. } else {
  467. failproccess(response, this.$notify)
  468. }
  469. })
  470. },
  471. createCancel(row) {
  472. console.log('点击了新增取消')
  473. for (let i = 0; i < this.table.list.length; i++) {
  474. if (row.myId === this.table.list[i].myId) {
  475. var listIndex = this.table.list.indexOf(this.table.list[i])
  476. }
  477. if (listIndex > -1) {
  478. this.table.list.splice(listIndex, 1)
  479. return
  480. }
  481. }
  482. },
  483. handleCreate2(row) {
  484. this.$router.push({ name: 'ChartPanel', params: { id: 'create', isEdit: 'edit' } })
  485. Cookies.set('ChartPanelIsEdit', 'edit')
  486. Cookies.set('ChartPanelIsEditId', 'create')
  487. },
  488. jumpSee(row) {
  489. console.log('点击了查看', row)
  490. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'view' } })
  491. Cookies.set('AddboardIsEdit', 'view')
  492. Cookies.set('AddboardIsEditId', row.id)
  493. localStorage.setItem("AddboardIsEditId", row.id)
  494. },
  495. jumpEdit(row) {
  496. console.log('点击了编辑', row)
  497. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'edit' } })
  498. Cookies.set('AddboardIsEdit', 'edit')
  499. Cookies.set('AddboardIsEditId', row.id)
  500. localStorage.setItem("AddboardIsEditId", row.id)
  501. },
  502. jumpSee2(row) {
  503. console.log('点击了查看', row)
  504. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'view' } })
  505. Cookies.set('ChartPanelIsEdit', 'view')
  506. Cookies.set('ChartPanelIsEditId', row.id)
  507. localStorage.setItem("ChartPanelIsEditId", row.id)
  508. },
  509. jumpEdit2(row) {
  510. console.log('点击了编辑', row)
  511. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'edit' } })
  512. Cookies.set('ChartPanelIsEdit', 'edit')
  513. Cookies.set('ChartPanelIsEditId', row.id)
  514. localStorage.setItem("ChartPanelIsEditId", row.id)
  515. },
  516. handleUpdate(row) {
  517. console.log('点击了设置', row)
  518. for (let i = 0; i < this.table.list.length; i++) {
  519. if (this.table.list[i].Edit == true) {
  520. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  521. return false
  522. }
  523. }
  524. // 编辑true,不可编辑false
  525. row.Edit = true
  526. row.NoEdit = false
  527. // 新增false,编辑false,编辑保存true
  528. row.isCreate = false
  529. row.isUpdate = false
  530. row.isUpdateSave = true
  531. // console.log(row.parentid)
  532. row.statue = String(row.statue)
  533. console.log("row.statue ", row.statue)
  534. this.table.temp.statue = row.statue
  535. this.table.temp.statueid = row.statueid
  536. this.table.temp.parentname = row.parentname
  537. },
  538. handleUpdate2(row) {
  539. console.log('点击了设置', row)
  540. for (let i = 0; i < this.table2.list.length; i++) {
  541. if (this.table2.list[i].Edit == true) {
  542. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  543. return false
  544. }
  545. }
  546. // 编辑true,不可编辑false
  547. row.Edit = true
  548. row.NoEdit = false
  549. // 新增false,编辑false,编辑保存true
  550. row.isCreate = false
  551. row.isUpdate = false
  552. row.isUpdateSave = true
  553. // console.log(row.parentid)
  554. row.statue = String(row.statue)
  555. this.table2.temp.statue = row.statue
  556. this.table2.temp.statueid = row.statueid
  557. },
  558. updateData(row) {
  559. console.log('点击了编辑保存')
  560. this.table.temp.pastureid = Cookies.get('pastureid')
  561. this.table.temp.dname = row.dname
  562. this.table.temp.display = row.display
  563. this.table.temp.reportenable = row.reportenable
  564. this.table.temp.emp = row.emp
  565. this.table.temp.opratetime = row.opratetime
  566. this.table.temp.id = row.id
  567. this.table.temp.statue = row.statue
  568. this.table.temp.rolenamesId = row.rolenamesId
  569. console.log(this.table.temp.rolenamesId)
  570. var rolenamesIdArr = []
  571. this.table.temp.rolenamesId.forEach(function (i, j) {
  572. rolenamesIdArr.push({ "id": i })
  573. })
  574. // 仪表盘名称/状态是否为空
  575. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  576. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  577. return false
  578. } else if (this.table.temp.dname == '') {
  579. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  580. return false
  581. }
  582. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  583. if (pattern.test(this.table.temp.dname)) {
  584. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  585. return false
  586. }
  587. this.isokDisable = true
  588. setTimeout(() => {
  589. this.isokDisable = false
  590. }, 1000)
  591. console.log(this.table.temp)
  592. var send_data3 = {
  593. 'common': { 'returnmap': '0' },
  594. 'data': [
  595. {
  596. 'name': 'updateDashboard',
  597. 'type': 'e',
  598. 'parammaps': this.table.temp
  599. },
  600. {
  601. 'name': 'deleteDrole',
  602. 'type': 'e',
  603. 'parammaps': {
  604. 'id': row.id,
  605. 'pastureid': Cookies.get('pastureid')
  606. }
  607. },
  608. {
  609. 'name': 'insertSpotList',
  610. 'resultmaps': {
  611. 'list': rolenamesIdArr
  612. },
  613. 'children': [
  614. {
  615. 'name': 'insertDrole',
  616. 'type': 'e',
  617. 'parammaps':
  618. {
  619. 'id': row.id,
  620. 'pastureid': Cookies.get('pastureid'),
  621. 'roleid': '@insertSpotList.id'
  622. }
  623. }
  624. ]
  625. }
  626. ]
  627. }
  628. ExecDataByConfig(send_data3).then(response => {
  629. if (response.msg !== 'fail') {
  630. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  631. this.getList()
  632. } else {
  633. failproccess(response, this.$notify)
  634. }
  635. })
  636. },
  637. updateData2(row) {
  638. console.log('点击了编辑保存')
  639. this.table2.temp.pastureid = Cookies.get('pastureid')
  640. this.table2.temp.cname = row.cname
  641. this.table2.temp.display = row.display
  642. this.table2.temp.emp = row.emp
  643. this.table2.temp.opratetime = row.opratetime
  644. this.table2.temp.id = row.id
  645. this.table2.temp.statue = row.statue
  646. // 仪表盘名称/状态是否为空
  647. if (this.table2.temp.dname == '' && this.table.temp.statue == '') {
  648. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  649. return false
  650. } else if (this.table2.temp.dname == '') {
  651. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  652. return false
  653. }
  654. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  655. if (pattern.test(this.table2.temp.dname)) {
  656. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  657. return false
  658. }
  659. this.isokDisable = true
  660. setTimeout(() => {
  661. this.isokDisable = false
  662. }, 1000)
  663. console.log(this.table2.temp)
  664. var send_data3 = {
  665. 'name': 'updateChart',
  666. 'parammaps': this.table2.temp
  667. }
  668. PostDataByName(send_data3).then(response => {
  669. console.log('新增保存发送参数', send_data3)
  670. if (response.msg !== 'fail') {
  671. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  672. this.getList2()
  673. } else {
  674. failproccess(response, this.$notify)
  675. }
  676. })
  677. },
  678. updateCancel(row) {
  679. console.log('点击了编辑取消')
  680. // 编辑false,不可编辑true
  681. row.Edit = false
  682. row.NoEdit = true
  683. // 新增false,编辑true,编辑保存false
  684. row.isCreate = false
  685. row.isUpdate = true
  686. row.isUpdateSave = false
  687. row.rolenamesId = row.rolenamesId2B
  688. },
  689. updateCancel2(row) {
  690. console.log('点击了编辑取消')
  691. // 编辑false,不可编辑true
  692. row.Edit = false
  693. row.NoEdit = true
  694. // 新增false,编辑true,编辑保存false
  695. row.isCreate = false
  696. row.isUpdate = true
  697. row.isUpdateSave = false
  698. },
  699. handleRowDelete(row) {
  700. console.log('点击了行内删除')
  701. MessageBox.confirm('是否确认删除此信息?', {
  702. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  703. }).then(() => {
  704. this.requestParam.name = 'deleteDashboard'
  705. this.requestParam.parammaps = {}
  706. this.requestParam.parammaps.pastureid = row.pastureid
  707. this.requestParam.parammaps.id = row.id
  708. PostDataByName(this.requestParam).then(response => {
  709. if (response.msg === 'fail') {
  710. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  711. } else {
  712. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  713. this.getList()
  714. }
  715. })
  716. }).catch(() => {
  717. this.$message({ type: 'info', message: '已取消删除' })
  718. })
  719. },
  720. handleRowDelete2(row) {
  721. console.log('点击了行内删除')
  722. MessageBox.confirm('是否确认删除此信息?', {
  723. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  724. }).then(() => {
  725. this.requestParam.name = 'deleteChart'
  726. this.requestParam.parammaps = {}
  727. this.requestParam.parammaps.pastureid = row.pastureid
  728. this.requestParam.parammaps.id = row.id
  729. PostDataByName(this.requestParam).then(response => {
  730. if (response.msg === 'fail') {
  731. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  732. } else {
  733. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  734. this.getList2()
  735. }
  736. })
  737. }).catch(() => {
  738. this.$message({ type: 'info', message: '已取消删除' })
  739. })
  740. }
  741. }
  742. }
  743. </script>
  744. <style lang="scss" scoped>
  745. .search {
  746. margin-top: 10px;
  747. }
  748. .table {
  749. margin-top: 10px;
  750. }
  751. </style>