5e448c43add81a83e68d39ce6c4c8d2765a7c7d1.svn-base 33 KB

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