be547999ef7ed0f570d8313d380ff18273149427.svn-base 33 KB

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