423b9c795ead2e4a171ca3566b780e428528f040.svn-base 36 KB

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