78b1cc9d5344d8a56fbb8c33e8d36ecc82b2fb55.svn-base 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  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 v-if="isRoleEdit" 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="180px" 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="180px" 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="100px" 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="150px" 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="90px" 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="90px" 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="90px" 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 v-if="isRoleEdit" 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 && isRoleEdit" class="miniSuccess" :disabled="isokDisable" icon="el-icon-folder-checked" @click="createData(row)" />
  89. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  90. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel(row)" />
  91. <!-- 编辑 -->
  92. <el-button v-if="row.isUpdate &&isRoleEdit" class="miniSuccess" :disabled="row.empid != empid" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  93. <span v-if="row.isUpdate &&isRoleEdit" class="centerSpan">|</span>
  94. <el-button v-if="row.isUpdate &&isRoleEdit" class="miniDanger" :disabled="row.empid != empid" icon="el-icon-delete" @click="handleRowDelete(row)" />
  95. <!-- 编辑保存 -->
  96. <el-button v-if="row.isUpdateSave && isRoleEdit" class="miniSuccess" :disabled="isokDisable" icon="el-icon-folder-checked" @click="updateData(row)" />
  97. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  98. <el-button v-if="row.isUpdateSave && isRoleEdit" 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 v-if="isRoleEdit" 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="90px" 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="90px" 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 v-if="isRoleEdit" class="centerSpan">|</span>
  175. <a v-if="isRoleEdit" class="correcting" :disabled="row.empid != empid" @click="jumpEdit2(row)">修改图表</a>
  176. <span v-if="isRoleEdit" class="centerSpan">|</span>
  177. <!-- 新增 -->
  178. <el-button v-if="row.isCreate && isRoleEdit" class="miniSuccess" :disabled="isokDisable" icon="el-icon-folder-checked" @click="createData2(row)" />
  179. <span v-if="row.isCreate && isRoleEdit" class="centerSpan">|</span>
  180. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" icon="el-icon-close" @click="createCancel2(row)" />
  181. <!-- 编辑 -->
  182. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" :disabled="row.empid != empid" icon="el-icon-edit-outline" @click="handleUpdate2(row)" />
  183. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  184. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" :disabled="row.empid != empid" icon="el-icon-delete" @click="handleRowDelete2(row)" />
  185. <!-- 编辑保存 -->
  186. <el-button v-if="row.isUpdateSave && isRoleEdit" class="miniSuccess" :disabled="isokDisable" icon="el-icon-folder-checked" @click="updateData2(row)" />
  187. <span v-if="row.isUpdateSave && isRoleEdit" class="centerSpan">|</span>
  188. <el-button v-if="row.isUpdateSave && isRoleEdit" 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. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  207. <el-button class="cancelClose" @click="editDialogVisible = false">取消</el-button>
  208. <el-button class="save" @click="handleSubmit"> 确认</el-button>
  209. </div>
  210. </el-dialog>
  211. </div>
  212. </template>
  213. <script>
  214. import { GetDataByName, GetDataByNames, PostDataByName, failproccess, ExecDataByConfig, checkButtons } 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: parseInt(Cookies.get('pageCount')),
  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: parseInt(Cookies.get('pageCount')),
  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. isRoleEdit: []
  289. }
  290. },
  291. created() {
  292. this.getList()
  293. this.getList2()
  294. this.getDownList()
  295. this.getButtons()
  296. if (this.$route.params.tab == 'second') {
  297. this.activeName = 'second'
  298. } else {
  299. this.activeName = 'first'
  300. }
  301. },
  302. methods: {
  303. getButtons() {
  304. const Edit = 'BoardEchartManagement'
  305. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  306. this.isRoleEdit = isRoleEdit
  307. },
  308. handleClick(tab, event) {
  309. console.log(tab, event)
  310. },
  311. getDownList() {
  312. GetDataByNames(this.requestParams).then(response => {
  313. console.log('下拉框数据', response.data)
  314. this.roleList = response.data.getRoleAll.list
  315. })
  316. },
  317. getList() {
  318. this.table.listLoading = true
  319. console.log(this.table.getdataListParm)
  320. GetDataByName(this.table.getdataListParm).then(response => {
  321. console.log('table数据', 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. var arr = response.data.list
  331. arr.map(function(i, j) {
  332. // console.log(i, '====')
  333. if (i.roleids) {
  334. return i.rolenamesId = i.roleids.split(',')
  335. } else {
  336. return i.rolenamesId = []
  337. }
  338. })
  339. arr.map(function(i, j) {
  340. if (i.roleids) {
  341. return i.rolenamesId2B = i.roleids.split(',')
  342. } else {
  343. return i.rolenamesId2B = []
  344. }
  345. })
  346. this.table.list = arr
  347. this.table.pageNum = response.data.pageNum
  348. this.table.pageSize = response.data.pageSize
  349. this.table.total = response.data.total
  350. } else {
  351. this.table.list = []
  352. }
  353. setTimeout(() => {
  354. this.table.listLoading = false
  355. }, 100)
  356. })
  357. },
  358. getList2() {
  359. this.table2.listLoading = true
  360. console.log(this.table2.getdataListParm)
  361. GetDataByName(this.table2.getdataListParm).then(response => {
  362. console.log('table2数据', response.data.list)
  363. if (response.data.list !== null) {
  364. for (let i = 0; i < response.data.list.length; i++) {
  365. this.$set(response.data.list[i], 'Edit', false) // 编辑
  366. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  367. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  368. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  369. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  370. }
  371. this.table2.list = response.data.list
  372. this.table2.pageNum = response.data.pageNum
  373. this.table2.pageSize = response.data.pageSize
  374. this.table2.total = response.data.total
  375. } else {
  376. this.table2.list = []
  377. }
  378. setTimeout(() => {
  379. this.table2.listLoading = false
  380. }, 100)
  381. })
  382. },
  383. handleEnableChange(val) {
  384. console.log('点击了是否启用', val)
  385. },
  386. handleSearch() {
  387. console.log('点击了查询')
  388. this.table.getdataListParm.offset = 1
  389. this.getList()
  390. },
  391. handleSearch2() {
  392. console.log('点击了查询')
  393. this.table2.getdataListParm.offset = 1
  394. this.getList2()
  395. },
  396. handleRefresh() {
  397. console.log('点击了重置')
  398. this.table.getdataListParm.parammaps.cname = ''
  399. this.table.getdataListParm.parammaps.dname = ''
  400. this.table.getdataListParm.parammaps.statue = ''
  401. this.table.getdataListParm.offset = 1
  402. this.getList()
  403. },
  404. handleRefresh2() {
  405. console.log('点击了重置')
  406. this.table2.getdataListParm.parammaps.cname = ''
  407. this.table2.getdataListParm.parammaps.dname = ''
  408. this.table2.getdataListParm.parammaps.statue = ''
  409. this.table2.getdataListParm.offset = 1
  410. this.getList2()
  411. },
  412. // changeParent(val) {
  413. // console.log('点击了牲畜类别父类', val)
  414. // console.log(this.parentList.find(obj => obj.value == val).label)
  415. // this.table.temp.parentname = this.parentList.find(obj => obj.value == val).label
  416. // },id
  417. changeStatue(val) {
  418. console.log('点击了状态', val)
  419. // console.log(this.statueList.find(obj => obj.value == val).id)
  420. this.table.temp.statueid = val
  421. this.table.temp.statue = val
  422. },
  423. changeStatue2(val) {
  424. console.log('点击了状态', val)
  425. // console.log(this.statueList.find(obj => obj.value == val).id)
  426. this.table2.temp.statueid = val
  427. this.table2.temp.statue = val
  428. },
  429. changeRole(val) {
  430. console.log('点击了角色', val)
  431. console.log('this.table.list', this.table.list)
  432. var arr = []
  433. this.roleList.forEach(function(i) {
  434. val.forEach(function(j) {
  435. if (i.id == j) {
  436. arr.push(i)
  437. }
  438. })
  439. })
  440. console.log('点击了角色', arr)
  441. this.table.temp.rolenamesId = arr
  442. this.rolenamesIdTempArr = arr
  443. },
  444. handleCreate() {
  445. this.editDialogVisible = true
  446. },
  447. handleSubmit() {
  448. var data = {
  449. name: 'insertDashboard',
  450. parammaps: {
  451. dname: this.dbObj.dname,
  452. display: this.dbObj.display,
  453. pastureid: Cookies.get('pastureid'),
  454. empid: Cookies.get('employeid'),
  455. emp: Cookies.get('employename')
  456. }
  457. }
  458. PostDataByName(data).then(res => {
  459. console.log('新增保存发送参数', data)
  460. this.$message({
  461. type: 'success',
  462. message: this.$t('common.saveSuccess')
  463. })
  464. this.editDialogVisible = false
  465. console.log('res', res)
  466. if (res.data.LastInsertId) {
  467. this.$router.push({ name: 'Addboard', params: { id: res.data.LastInsertId, isEdit: 'create' }})
  468. Cookies.set('AddboardIsEdit', 'create')
  469. Cookies.set('AddboardIsEditId', res.data.LastInsertId)
  470. localStorage.setItem('AddboardIsEditId', res.data.LastInsertId)
  471. }
  472. })
  473. },
  474. createData(row) {
  475. console.log('点击了新增保存')
  476. this.table.temp.pastureid = Cookies.get('pastureid')
  477. this.table.temp.dname = row.dname
  478. this.table.temp.display = row.display
  479. this.table.temp.statue = row.statue
  480. this.table.temp.reportenable = row.reportenable
  481. this.table.temp.emp = row.emp
  482. this.table.temp.opratetime = row.opratetime
  483. // 仪表盘名称/状态是否为空
  484. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  485. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  486. return false
  487. } else if (this.table.temp.dname == '') {
  488. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  489. return false
  490. }
  491. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  492. if (pattern.test(this.table.temp.dname)) {
  493. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  494. return false
  495. }
  496. this.isokDisable = true
  497. setTimeout(() => {
  498. this.isokDisable = false
  499. }, 1000)
  500. this.requestParam.name = 'insertDashboard'
  501. this.requestParam.parammaps = this.table.temp
  502. PostDataByName(this.requestParam).then(response => {
  503. console.log('新增保存发送参数', this.requestParam)
  504. if (response.msg !== 'fail') {
  505. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  506. this.getList()
  507. } else {
  508. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  509. }
  510. })
  511. },
  512. createCancel(row) {
  513. console.log('点击了新增取消')
  514. for (let i = 0; i < this.table.list.length; i++) {
  515. if (row.myId === this.table.list[i].myId) {
  516. var listIndex = this.table.list.indexOf(this.table.list[i])
  517. }
  518. if (listIndex > -1) {
  519. this.table.list.splice(listIndex, 1)
  520. return
  521. }
  522. }
  523. },
  524. handleCreate2(row) {
  525. this.$router.push({ name: 'ChartPanel', params: { id: 'create', isEdit: 'edit' }})
  526. Cookies.set('ChartPanelIsEdit', 'edit')
  527. Cookies.set('ChartPanelIsEditId', 'create')
  528. localStorage.setItem('ChartPanelIsEditId', 'create')
  529. },
  530. jumpSee(row) {
  531. console.log('点击了查看', row)
  532. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'view', isRoleEdit: this.isRoleEdit }})
  533. Cookies.set('AddboardIsEdit', 'view')
  534. Cookies.set('AddboardIsEditId', row.id)
  535. localStorage.setItem('AddboardIsEditId', row.id)
  536. },
  537. jumpEdit(row) {
  538. console.log('点击了编辑', row)
  539. this.$router.push({ name: 'Addboard', params: { id: row.id, isEdit: 'edit' }})
  540. Cookies.set('AddboardIsEdit', 'edit')
  541. Cookies.set('AddboardIsEditId', row.id)
  542. localStorage.setItem('AddboardIsEditId', row.id)
  543. },
  544. jumpSee2(row) {
  545. console.log('点击了查看', row)
  546. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'view', isRoleEdit: this.isRoleEdit }})
  547. Cookies.set('ChartPanelIsEdit', 'view')
  548. Cookies.set('ChartPanelIsEditId', row.id)
  549. localStorage.setItem('ChartPanelIsEditId', row.id)
  550. localStorage.setItem('ChartPanelIsEdit', 'view')
  551. this.$store.state.user.dashchartid = row.id
  552. this.$store.state.user.dashchartidisedit = 'view'
  553. },
  554. jumpEdit2(row) {
  555. console.log('点击了编辑', row)
  556. this.$router.push({ name: 'ChartPanel', params: { id: row.id, isEdit: 'edit' }})
  557. Cookies.set('ChartPanelIsEdit', 'edit')
  558. Cookies.set('ChartPanelIsEditId', row.id)
  559. localStorage.setItem('ChartPanelIsEditId', row.id)
  560. localStorage.setItem('ChartPanelIsEdit', 'edit')
  561. this.$store.state.user.dashchartid = row.id
  562. this.$store.state.user.dashchartidisedit = 'edit'
  563. },
  564. handleUpdate(row) {
  565. console.log('点击了设置', row)
  566. for (let i = 0; i < this.table.list.length; i++) {
  567. if (this.table.list[i].Edit == true) {
  568. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  569. return false
  570. }
  571. }
  572. // 编辑true,不可编辑false
  573. row.Edit = true
  574. row.NoEdit = false
  575. // 新增false,编辑false,编辑保存true
  576. row.isCreate = false
  577. row.isUpdate = false
  578. row.isUpdateSave = true
  579. // console.log(row.parentid)
  580. row.statue = String(row.statue)
  581. console.log('row.statue ', row.statue)
  582. this.table.temp.statue = row.statue
  583. this.table.temp.statueid = row.statueid
  584. this.table.temp.parentname = row.parentname
  585. },
  586. handleUpdate2(row) {
  587. console.log('点击了设置', row)
  588. for (let i = 0; i < this.table2.list.length; i++) {
  589. if (this.table2.list[i].Edit == true) {
  590. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  591. return false
  592. }
  593. }
  594. // 编辑true,不可编辑false
  595. row.Edit = true
  596. row.NoEdit = false
  597. // 新增false,编辑false,编辑保存true
  598. row.isCreate = false
  599. row.isUpdate = false
  600. row.isUpdateSave = true
  601. // console.log(row.parentid)
  602. row.statue = String(row.statue)
  603. this.table2.temp.statue = row.statue
  604. this.table2.temp.statueid = row.statueid
  605. },
  606. updateData(row) {
  607. console.log('点击了编辑保存')
  608. this.table.temp.pastureid = Cookies.get('pastureid')
  609. this.table.temp.dname = row.dname
  610. this.table.temp.display = row.display
  611. this.table.temp.reportenable = row.reportenable
  612. this.table.temp.emp = row.emp
  613. this.table.temp.opratetime = row.opratetime
  614. this.table.temp.id = row.id
  615. this.table.temp.statue = row.statue
  616. this.table.temp.rolenamesId = row.rolenamesId
  617. console.log(this.table.temp.rolenamesId)
  618. var rolenamesIdArr = []
  619. this.table.temp.rolenamesId.forEach(function(i, j) {
  620. rolenamesIdArr.push({ 'id': i })
  621. })
  622. // 仪表盘名称/状态是否为空
  623. if (this.table.temp.dname == '' && this.table.temp.statue == '') {
  624. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  625. return false
  626. } else if (this.table.temp.dname == '') {
  627. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  628. return false
  629. }
  630. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  631. if (pattern.test(this.table.temp.dname)) {
  632. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  633. return false
  634. }
  635. this.isokDisable = true
  636. setTimeout(() => {
  637. this.isokDisable = false
  638. }, 1000)
  639. console.log(this.table.temp)
  640. var send_data3 = {
  641. 'common': { 'returnmap': '0' },
  642. 'data': [
  643. {
  644. 'name': 'updateDashboard',
  645. 'type': 'e',
  646. 'parammaps': this.table.temp
  647. },
  648. {
  649. 'name': 'deleteDrole',
  650. 'type': 'e',
  651. 'parammaps': {
  652. 'id': row.id,
  653. 'pastureid': Cookies.get('pastureid')
  654. }
  655. },
  656. {
  657. 'name': 'insertSpotList',
  658. 'resultmaps': {
  659. 'list': rolenamesIdArr
  660. },
  661. 'children': [
  662. {
  663. 'name': 'insertDrole',
  664. 'type': 'e',
  665. 'parammaps':
  666. {
  667. 'id': row.id,
  668. 'pastureid': Cookies.get('pastureid'),
  669. 'roleid': '@insertSpotList.id'
  670. }
  671. }
  672. ]
  673. }
  674. ]
  675. }
  676. ExecDataByConfig(send_data3).then(response => {
  677. if (response.msg !== 'fail') {
  678. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  679. this.getList()
  680. } else {
  681. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  682. }
  683. })
  684. },
  685. updateData2(row) {
  686. console.log('点击了编辑保存')
  687. this.table2.temp.pastureid = Cookies.get('pastureid')
  688. this.table2.temp.cname = row.cname
  689. this.table2.temp.display = row.display
  690. this.table2.temp.emp = row.emp
  691. this.table2.temp.opratetime = row.opratetime
  692. this.table2.temp.id = row.id
  693. this.table2.temp.statue = row.statue
  694. // 仪表盘名称/状态是否为空
  695. if (this.table2.temp.dname == '' && this.table.temp.statue == '') {
  696. this.$message({ type: 'error', message: '仪表盘名称/状态不能为空', duration: 2000 })
  697. return false
  698. } else if (this.table2.temp.dname == '') {
  699. this.$message({ type: 'error', message: '仪表盘名称不能为空', duration: 2000 })
  700. return false
  701. }
  702. const pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  703. if (pattern.test(this.table2.temp.dname)) {
  704. this.$message({ type: 'error', message: '仪表盘名称不可输入特殊字符', duration: 2000 })
  705. return false
  706. }
  707. this.isokDisable = true
  708. setTimeout(() => {
  709. this.isokDisable = false
  710. }, 1000)
  711. console.log(this.table2.temp)
  712. var send_data3 = {
  713. 'name': 'updateChart',
  714. 'parammaps': this.table2.temp
  715. }
  716. PostDataByName(send_data3).then(response => {
  717. console.log('新增保存发送参数', send_data3)
  718. if (response.msg !== 'fail') {
  719. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  720. this.getList2()
  721. } else {
  722. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  723. }
  724. })
  725. },
  726. updateCancel(row) {
  727. console.log('点击了编辑取消')
  728. // 编辑false,不可编辑true
  729. row.Edit = false
  730. row.NoEdit = true
  731. // 新增false,编辑true,编辑保存false
  732. row.isCreate = false
  733. row.isUpdate = true
  734. row.isUpdateSave = false
  735. row.rolenamesId = row.rolenamesId2B
  736. },
  737. updateCancel2(row) {
  738. console.log('点击了编辑取消')
  739. // 编辑false,不可编辑true
  740. row.Edit = false
  741. row.NoEdit = true
  742. // 新增false,编辑true,编辑保存false
  743. row.isCreate = false
  744. row.isUpdate = true
  745. row.isUpdateSave = false
  746. },
  747. handleRowDelete(row) {
  748. console.log('点击了行内删除')
  749. MessageBox.confirm('是否确认删除此信息?', {
  750. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  751. }).then(() => {
  752. this.requestParam.name = 'deleteDashboard'
  753. this.requestParam.parammaps = {}
  754. this.requestParam.parammaps.pastureid = row.pastureid
  755. this.requestParam.parammaps.id = row.id
  756. PostDataByName(this.requestParam).then(response => {
  757. if (response.msg === 'fail') {
  758. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  759. } else {
  760. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  761. this.getList()
  762. }
  763. })
  764. }).catch(() => {
  765. this.$message({ type: 'info', message: '已取消删除' })
  766. })
  767. },
  768. handleRowDelete2(row) {
  769. console.log('点击了行内删除')
  770. var send_data = {
  771. 'name': 'getChartuseCount',
  772. 'parammaps': {
  773. 'pastureid': Cookies.get('pastureid'),
  774. 'id': row.id
  775. }
  776. }
  777. GetDataByName(send_data).then(res => {
  778. console.log(res)
  779. if (res.data.list[0].cou > 0) {
  780. MessageBox.confirm('当前图表已被引用,是否进行删除?', {
  781. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  782. }).then(() => {
  783. this.requestParam.name = 'deleteChart'
  784. this.requestParam.parammaps = {}
  785. this.requestParam.parammaps.pastureid = row.pastureid
  786. this.requestParam.parammaps.id = row.id
  787. PostDataByName(this.requestParam).then(response => {
  788. if (response.msg === 'fail') {
  789. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  790. } else {
  791. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  792. this.getList2()
  793. }
  794. })
  795. }).catch(() => {
  796. this.$message({ type: 'info', message: '已取消删除' })
  797. })
  798. } else {
  799. this.requestParam.name = 'deleteChart'
  800. this.requestParam.parammaps = {}
  801. this.requestParam.parammaps.pastureid = row.pastureid
  802. this.requestParam.parammaps.id = row.id
  803. PostDataByName(this.requestParam).then(response => {
  804. if (response.msg === 'fail') {
  805. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  806. } else {
  807. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  808. this.getList2()
  809. }
  810. })
  811. }
  812. })
  813. // MessageBox.confirm('当前图表已被引用,是否进行删除?', {
  814. // confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  815. // }).then(() => {
  816. // this.requestParam.name = 'deleteChart'
  817. // this.requestParam.parammaps = {}
  818. // this.requestParam.parammaps.pastureid = row.pastureid
  819. // this.requestParam.parammaps.id = row.id
  820. // PostDataByName(this.requestParam).then(response => {
  821. // if (response.msg === 'fail') {
  822. // this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  823. // } else {
  824. // this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  825. // this.getList2()
  826. // }
  827. // })
  828. // }).catch(() => {
  829. // this.$message({ type: 'info', message: '已取消删除' })
  830. // })
  831. }
  832. }
  833. }
  834. </script>
  835. <style lang="scss" scoped>
  836. .search {
  837. margin-top: 10px;
  838. }
  839. .table {
  840. margin-top: 10px;
  841. }
  842. </style>