2e6a9ed809bbb8be914fde785bc10c3e2754dcd1.svn-base 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button v-if="isRoleEdit" class="success" @click="handleCreate">新增</el-button>
  5. </div>
  6. <div class="search">
  7. <el-input v-model="tab1.table.getdataListParm.parammaps.groupsname" placeholder="集团名称" style="width: 180px;" class="filter-item" clearable />
  8. <el-select v-model="tab1.table.getdataListParm.parammaps.enable" placeholder="状态" class="filter-item" style="width: 120px;" clearable>
  9. <el-option v-for="item in stateList" :key="item.id" :label="item.name" :value="item.id" />
  10. </el-select>
  11. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  12. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  13. </div>
  14. <div class="table">
  15. <el-table
  16. :key="tab1.table.tableKey"
  17. v-loading="tab1.table.listLoading"
  18. element-loading-text="给我一点时间"
  19. :data="tab1.table.list"
  20. border
  21. fit
  22. highlight-current-row
  23. style="width: 100%;"
  24. :row-style="rowStyle"
  25. :cell-style="cellStyle"
  26. class="elTable table-fixed"
  27. >
  28. <el-table-column label="序号" align="center" type="index" width="50px">
  29. <template slot-scope="scope">
  30. <span>{{ scope.$index + (tab1.table.pageNum-1) * tab1.table.pageSize + 1 }}</span>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="集团ID" min-width="130px" align="center">
  34. <template slot-scope="scope">
  35. <span v-if="scope.row.NoEdit">{{ scope.row.groupscode }}</span>
  36. <el-input v-if="scope.row.Edit" v-model="scope.row.groupscode" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" placeholder="1-32字符" style="width:95%;padding:10px 0;" />
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="集团名称" min-width="130px" align="center">
  40. <template slot-scope="scope">
  41. <span v-if="scope.row.NoEdit">{{ scope.row.groupsname }}</span>
  42. <el-input v-if="scope.row.Edit" v-model="scope.row.groupsname" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" placeholder="1-32字符" style="width:95%;padding:10px 0;" />
  43. </template>
  44. </el-table-column>
  45. <el-table-column label="联系人" min-width="130px" align="center">
  46. <template slot-scope="scope">
  47. <span v-if="scope.row.NoEdit">{{ scope.row.emp }}</span>
  48. <el-input v-if="scope.row.Edit" v-model="scope.row.emp" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" placeholder="1-32字符" style="width:95%;padding:10px 0;" />
  49. </template>
  50. </el-table-column>
  51. <el-table-column label="联系方式" min-width="130px" align="center">
  52. <template slot-scope="scope">
  53. <span v-if="scope.row.NoEdit">{{ scope.row.phone }}</span>
  54. <el-input v-if="scope.row.Edit" v-model.trim="scope.row.phone" placeholder="请输入11位手机号" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="11" style="width:95%;padding:10px 0;" />
  55. </template>
  56. </el-table-column>
  57. <el-table-column label="管理员用户名" min-width="130px" align="center">
  58. <template slot-scope="scope">
  59. <span v-if="scope.row.NoEdit">{{ scope.row.user }}</span>
  60. <el-input v-if="scope.row.Edit" v-model="scope.row.user" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="32" placeholder="1-32字符" style="width:95%;padding:10px 0;" />
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="状态" min-width="110px" align="center">
  64. <template slot-scope="scope">
  65. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="备注" min-width="130px" align="center">
  69. <template slot-scope="scope">
  70. <span v-if="scope.row.NoEdit">{{ scope.row.note }}</span>
  71. <el-input v-if="scope.row.Edit" v-model="scope.row.note" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" maxlength="255" placeholder="1-255字符" style="width:95%;padding:10px 0;" />
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
  75. <template slot-scope="{row}">
  76. <!-- 页面权限 -->
  77. <el-button v-if="row.NoEdit && isRoleEdit" class="miniSuccess" @click="handlePageConfiguration(row)">页面配置</el-button>
  78. <!-- 新增 -->
  79. <el-button v-if="row.isCreate && isRoleEdit" class="miniSuccess" :disabled="isokDisable" @click="createData(row)">保存</el-button>
  80. <el-button v-if="row.isCreate && isRoleEdit" class="minCancel" @click="createCancel(row)">取消</el-button>
  81. <!-- 编辑 -->
  82. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  83. <!-- 关联 -->
  84. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleRelation(row)">关联</el-button>
  85. <!-- 编辑保存 -->
  86. <el-button v-if="row.isUpdateSave && isRoleEdit" class="miniSuccess" :disabled="isokDisable" @click="updateData(row)">保存</el-button>
  87. <el-button v-if="row.isUpdateSave && isRoleEdit" class="minCancel" @click="updateCancel(row)">取消</el-button>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <pagination v-show="tab1.table.total>=0" :total="tab1.table.total" :page.sync="tab1.table.getdataListParm.offset" :limit.sync="tab1.table.getdataListParm.pagecount" @pagination="getList" />
  92. </div>
  93. <!-- 页面配置 -->
  94. <el-dialog :title="textMap[tab1.pageConfiguration.dialogStatus]" :visible.sync="tab1.pageConfiguration.dialogFormVisible" :close-on-click-modal="false" width="25%">
  95. <div style="height: 400px;overflow-y: auto;">
  96. <el-tree
  97. ref="tree"
  98. v-loading="tab1.pageConfiguration.listLoading"
  99. show-checkbox
  100. node-key="id"
  101. :default-expand-all="true"
  102. :data="tab1.pageConfiguration.data"
  103. :props="tab1.pageConfiguration.defaultProps"
  104. :default-checked-keys="tab1.pageConfiguration.defaultCheckedKeys"
  105. @check-change="handelCheckChange"
  106. />
  107. </div>
  108. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  109. <el-button @click="tab1.pageConfiguration.dialogFormVisible = false;getList(); ">取消</el-button>
  110. <el-button type="success" :disabled="isokDisable" @click="pageConfigurationData()">确认</el-button>
  111. </div>
  112. </el-dialog>
  113. <!-- 关联 -->
  114. <el-dialog :title="textMap[tab1.relation.dialogStatus]" :visible.sync="tab1.relation.dialogFormVisible" :close-on-click-modal="false" width="70%">
  115. <div>
  116. <el-form ref="relationTemp" :rules="rules" label-position="right" :model="tab1.relation.temp" label-width="130px" style="width: 100%;">
  117. <el-row>
  118. <el-col :span="8">
  119. <el-form-item label="集团名称:" prop="groupsname">
  120. <el-input ref="groupsname" v-model="tab1.relation.temp.groupsname" disabled class="filter-item" placeholder="集团名称" type="text" style="width:100%;" />
  121. </el-form-item>
  122. </el-col>
  123. </el-row>
  124. <el-row>
  125. <el-col :span="8">
  126. <el-form-item label="关联:" prop="radio">
  127. <el-radio-group v-model="tab1.relation.radio">
  128. <el-radio-button label="集团" />
  129. <el-radio-button label="牧场" />
  130. </el-radio-group>
  131. </el-form-item>
  132. </el-col>
  133. </el-row>
  134. <div v-if="tab1.relation.radio =='集团'" class="group">
  135. <el-row>
  136. <el-col :span="16">
  137. <el-form-item label="选择关联集团:">
  138. <el-autocomplete v-model="tab1.relation.group.groupsname" class="inline-input" :fetch-suggestions="groupSearch" placeholder="选择关联集团" style="width: 100%;" @select="handleGroupSelect">
  139. <template slot-scope="{ item }">
  140. <span class="addr"> 集团:{{ item.groupsname }}</span>
  141. </template>
  142. </el-autocomplete>
  143. </el-form-item>
  144. </el-col>
  145. </el-row>
  146. <div class="table">
  147. <el-table
  148. :key="tab1.relation.group.table.tableKey"
  149. v-loading="tab1.relation.group.table.listLoading"
  150. element-loading-text="给我一点时间"
  151. :data="tab1.relation.group.table.list"
  152. border
  153. fit
  154. highlight-current-row
  155. style="width: 100%;"
  156. :row-style="rowStyle"
  157. :cell-style="cellStyle"
  158. class="elTable table-fixed"
  159. >
  160. <el-table-column label="序号" align="center" type="index" width="50px" />
  161. <el-table-column label="集团ID" min-width="130px" align="center" prop="groupscode" />
  162. <el-table-column label="集团名称" min-width="130px" align="center" prop="groupsname" />
  163. <el-table-column label="管理员用户名" min-width="130px" align="center" prop="user" />
  164. <el-table-column label="状态" min-width="110px" align="center">
  165. <template slot-scope="scope">
  166. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  167. </template>
  168. </el-table-column>
  169. <el-table-column label="备注" min-width="130px" align="center" prop="note" />
  170. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
  171. <template slot-scope="{row}">
  172. <el-button class="miniDanger" @click="handleGroupDelete(row)">删除</el-button>
  173. </template>
  174. </el-table-column>
  175. </el-table>
  176. </div>
  177. </div>
  178. <div v-if="tab1.relation.radio =='牧场'" class="pasture">
  179. <el-row>
  180. <el-col :span="16">
  181. <el-form-item label="选择关联牧场:">
  182. <el-autocomplete v-model="tab1.relation.pasture.pastureName" class="inline-input" :fetch-suggestions="pastureSearch" placeholder="选择关联牧场" style="width: 100%;" @select="handlePastureSelect">
  183. <template slot-scope="{ item }">
  184. <span class="addr"> 牧场:{{ item.pasturename }}</span>
  185. </template>
  186. </el-autocomplete>
  187. </el-form-item>
  188. </el-col>
  189. </el-row>
  190. <div class="table">
  191. <el-table
  192. :key="tab1.relation.pasture.table.tableKey"
  193. v-loading="tab1.relation.pasture.table.listLoading"
  194. element-loading-text="给我一点时间"
  195. :data="tab1.relation.pasture.table.list"
  196. border
  197. fit
  198. highlight-current-row
  199. style="width: 100%;"
  200. :row-style="rowStyle"
  201. :cell-style="cellStyle"
  202. class="elTable table-fixed"
  203. >
  204. <el-table-column label="序号" align="center" type="index" width="50px" />
  205. <el-table-column label="牧场ID" min-width="130px" align="center" prop="pasturecode" />
  206. <el-table-column label="牧场名称" min-width="130px" align="center" prop="pasturename" />
  207. <el-table-column label="管理员用户名" min-width="130px" align="center" prop="user" />
  208. <el-table-column label="权限归属" min-width="130px" align="center" prop="groupsname" />
  209. <el-table-column label="状态" min-width="110px" align="center">
  210. <template slot-scope="scope">
  211. <el-switch v-model="scope.row.enable" disabled active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" />
  212. </template>
  213. </el-table-column>
  214. <el-table-column label="备注" min-width="130px" align="center" prop="note" />
  215. <el-table-column label="操作" align="center" width="300" class-name="small-padding fixed-width" fixed="right">
  216. <template slot-scope="{row}">
  217. <el-button class="miniDanger" @click="handlePastureDelete(row)">删除</el-button>
  218. </template>
  219. </el-table-column>
  220. </el-table>
  221. </div>
  222. </div>
  223. </el-form>
  224. </div>
  225. <div slot="footer" class="dialog-footer" style="right:30px;position:absolute;bottom:5px">
  226. <el-button @click="tab1.relation.dialogFormVisible = false;getList(); ">取消</el-button>
  227. <el-button v-if="tab1.relation.dialogStatus==='relation'" type="success" :disabled="isokDisable" @click="relationData()">确认</el-button>
  228. </div>
  229. </el-dialog>
  230. </div>
  231. </template>
  232. <script>
  233. import { GetDataByName, failproccess, transData, ExecDataByConfig, checkButtons } from '@/api/common'
  234. import Cookies from 'js-cookie'
  235. import { parseTime } from '@/utils/index.js'
  236. import { validate11Digits } from '@/utils/validate.js'
  237. import { MessageBox } from 'element-ui'
  238. import Pagination from '@/components/Pagination'
  239. export default {
  240. name: 'OperationManagement',
  241. components: { Pagination },
  242. data() {
  243. return {
  244. requestParams: [
  245. { name: 'getGroupsAllList', offset: 0, pagecount: 0, parammaps: {}}
  246. ],
  247. isRoleEdit: [],
  248. stateList: [{ id: 1, name: '启用' }, { id: 0, name: '禁止' }], // 状态
  249. tab1: {
  250. table: {
  251. getdataListParm: {
  252. name: 'getGroupsAllList',
  253. page: 1,
  254. offset: 1,
  255. pagecount: 10,
  256. returntype: 'Map',
  257. parammaps: {
  258. groupsname: '',
  259. enable: ''
  260. }
  261. },
  262. tableKey: 0,
  263. list: [],
  264. total: 0,
  265. listLoading: true,
  266. temp: {}
  267. },
  268. // 页面配置
  269. pageConfiguration: {
  270. dialogFormVisible: false,
  271. dialogStatus: '',
  272. temp: {},
  273. listLoading: true,
  274. getdataListParm: {
  275. name: 'getMenuandButtonlistJT'
  276. },
  277. parentType: [],
  278. defaultProps: {
  279. children: 'children',
  280. label: 'name'
  281. },
  282. defaultCheckedKeys: [],
  283. arrList: []
  284. },
  285. // 关联
  286. relation: {
  287. dialogFormVisible: false,
  288. dialogStatus: '',
  289. radio: '集团',
  290. temp: {},
  291. group: {
  292. requestParam: {
  293. name: 'getGroupsAllListV2',
  294. page: 1,
  295. offset: 1,
  296. pagecount: 10,
  297. returntype: 'Map',
  298. parammaps: {
  299. groupsname: ''
  300. }
  301. },
  302. searchList: [],
  303. table: {
  304. tableKey: 1,
  305. list: [],
  306. total: 0,
  307. listLoading: false,
  308. getdataListParm: {
  309. name: 'groupsrelationlistJT',
  310. page: 1,
  311. offset: 1,
  312. pagecount: 10,
  313. returntype: 'Map',
  314. parammaps: {
  315. groupsname: ''
  316. }
  317. }
  318. }
  319. },
  320. pasture: {
  321. requestParam: {
  322. name: 'groupsrelationlistMCAll',
  323. page: 1,
  324. offset: 1,
  325. pagecount: 10,
  326. returntype: 'Map',
  327. parammaps: {
  328. pastureName: ''
  329. }
  330. },
  331. searchList: [],
  332. table: {
  333. tableKey: 2,
  334. list: [],
  335. total: 0,
  336. listLoading: false,
  337. getdataListParm: {
  338. name: 'groupsrelationlistMC',
  339. page: 1,
  340. offset: 1,
  341. pagecount: 10,
  342. returntype: 'Map',
  343. parammaps: {
  344. pastureName: ''
  345. }
  346. }
  347. }
  348. }
  349. }
  350. },
  351. requestParam: {},
  352. rules: {},
  353. isokDisable: false,
  354. textMap: {
  355. pageConfiguration: '页面配置',
  356. relation: '关联'
  357. },
  358. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  359. cellStyle: { padding: 0 + 'px' }
  360. }
  361. },
  362. created() {
  363. this.getList()
  364. this.getButtons()
  365. },
  366. methods: {
  367. getButtons() {
  368. const Edit = 'Role'
  369. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  370. this.isRoleEdit = isRoleEdit
  371. },
  372. getList() {
  373. this.tab1.table.listLoading = true
  374. GetDataByName(this.tab1.table.getdataListParm).then(response => {
  375. console.log('table数据', response.data.list)
  376. if (response.data.list !== null) {
  377. for (let i = 0; i < response.data.list.length; i++) {
  378. this.$set(response.data.list[i], 'Edit', false) // 编辑
  379. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  380. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  381. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  382. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  383. }
  384. this.tab1.table.list = response.data.list
  385. this.tab1.table.pageNum = response.data.pageNum
  386. this.tab1.table.pageSize = response.data.pageSize
  387. this.tab1.table.total = response.data.total
  388. } else {
  389. this.tab1.table.list = []
  390. }
  391. setTimeout(() => {
  392. this.tab1.table.listLoading = false
  393. }, 100)
  394. })
  395. },
  396. handleSearch() {
  397. console.log('点击了查询')
  398. this.tab1.table.getdataListParm.offset = 1
  399. this.getList()
  400. },
  401. handleRefresh() {
  402. console.log('点击了重置')
  403. this.tab1.table.getdataListParm.parammaps.groupsname = ''
  404. this.tab1.table.getdataListParm.parammaps.enable = ''
  405. this.tab1.table.getdataListParm.offset = 1
  406. this.getList()
  407. },
  408. handleCreate() {
  409. console.log('点击了新增')
  410. // 编辑true/不可编辑false
  411. // 新增操true,编辑false,编辑保存false
  412. for (let i = 0; i < this.tab1.table.list.length; i++) {
  413. if (this.tab1.table.list[i].Edit == true) {
  414. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  415. return false
  416. }
  417. }
  418. this.tab1.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'groupscode': '', 'groupsname': '', 'emp': '', 'phone': '', 'user': '', 'note': '' })
  419. },
  420. createData(row) {
  421. // 检验集团ID/集团名称是否为空
  422. console.log(row)
  423. if (row.groupscode == '' && row.groupsname == '' && row.user == '') {
  424. this.$message({ type: 'error', message: '集团ID/集团名称/管理员用户名不能为空', duration: 2000 })
  425. return false
  426. } else if (row.groupsname == '' && row.user == '') {
  427. this.$message({ type: 'error', message: '集团名称/管理员用户名不能为空', duration: 2000 })
  428. return false
  429. } else if (row.groupscode == '') {
  430. this.$message({ type: 'error', message: '集团ID不能为空', duration: 2000 })
  431. return false
  432. } else if (row.groupsname == '') {
  433. this.$message({ type: 'error', message: '集团名称不能为空', duration: 2000 })
  434. return false
  435. } else if (row.user == '') {
  436. this.$message({ type: 'error', message: '管理员用户名不能为空', duration: 2000 })
  437. return false
  438. }
  439. if (row.phone !== undefined && row.phone !== '') {
  440. const phone = /^\d{11}$/
  441. if (!phone.test(row.phone)) {
  442. this.$message({ type: 'error', message: '请输入11位手机号', duration: 2000 })
  443. return false
  444. }
  445. }
  446. this.isokDisable = true
  447. setTimeout(() => {
  448. this.isokDisable = false
  449. }, 1000)
  450. this.requestParam = {}
  451. this.requestParam.common = { 'returnmap': '0' }
  452. this.requestParam.data = []
  453. this.requestParam.data[0] = { 'name': 'checkuser', 'type': 'v', 'parammaps': {
  454. 'user': row.user
  455. }}
  456. this.requestParam.data[1] = { 'name': 'insertGroups', 'type': 'e', 'parammaps': {
  457. 'groupsname': row.groupsname,
  458. 'groupscode': row.groupscode,
  459. 'emp': row.emp,
  460. 'phone': row.phone,
  461. 'enable': row.enable,
  462. 'note': row.note,
  463. 'user': row.user
  464. }}
  465. this.requestParam.data[2] = { 'name': 'createNewPasture', 'type': 'e', 'parammaps': {
  466. 'user': row.user,
  467. 'pastureid': '@insertGroups.LastInsertId',
  468. 'type': '1'
  469. }}
  470. ExecDataByConfig(this.requestParam).then(response => {
  471. console.log('新增保存发送参数', this.requestParam)
  472. if (response.msg !== 'fail') {
  473. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  474. this.getList()
  475. } else {
  476. const tId = new RegExp("column 'id'")
  477. if (tId.test(response.data)) {
  478. this.$notify({ title: '保存失败', message: '集团已存在,不可重复生成', type: 'warning', duration: 2000 })
  479. } else {
  480. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  481. }
  482. }
  483. })
  484. },
  485. createCancel(row) {
  486. console.log('点击了集团新增取消')
  487. for (let i = 0; i < this.tab1.table.list.length; i++) {
  488. if (row.myId === this.tab1.table.list[i].myId) {
  489. var listIndex = this.tab1.table.list.indexOf(this.tab1.table.list[i])
  490. }
  491. if (listIndex > -1) {
  492. this.tab1.table.list.splice(listIndex, 1)
  493. return
  494. }
  495. }
  496. },
  497. handleUpdate(row) {
  498. console.log('点击了编辑')
  499. for (let i = 0; i < this.tab1.table.list.length; i++) {
  500. if (this.tab1.table.list[i].Edit == true) {
  501. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  502. return false
  503. }
  504. }
  505. // 编辑true,不可编辑false
  506. row.Edit = true
  507. row.NoEdit = false
  508. // 新增false,编辑false,编辑保存true
  509. row.isCreate = false
  510. row.isUpdate = false
  511. row.isUpdateSave = true
  512. },
  513. updateData(row) {
  514. if (row.pasturecode == '' && row.pasturename == '' && row.user == '') {
  515. this.$message({ type: 'error', message: '牧场ID/牧场名称/管理员用户名不能为空', duration: 2000 })
  516. return false
  517. } else if (row.pasturename == '' && row.user == '') {
  518. this.$message({ type: 'error', message: '牧场名称/管理员用户名不能为空', duration: 2000 })
  519. return false
  520. } else if (row.pasturecode == '') {
  521. this.$message({ type: 'error', message: '牧场ID不能为空', duration: 2000 })
  522. return false
  523. } else if (row.pasturename == '') {
  524. this.$message({ type: 'error', message: '牧场名称不能为空', duration: 2000 })
  525. return false
  526. } else if (row.user == '') {
  527. this.$message({ type: 'error', message: '管理员用户名不能为空', duration: 2000 })
  528. return false
  529. }
  530. if (row.phone !== undefined && row.phone !== '') {
  531. const phone = /^\d{11}$/
  532. if (!phone.test(row.phone)) {
  533. this.$message({ type: 'error', message: '请输入11位手机号', duration: 2000 })
  534. return false
  535. }
  536. }
  537. this.isokDisable = true
  538. setTimeout(() => {
  539. this.isokDisable = false
  540. }, 1000)
  541. this.requestParam = {}
  542. this.requestParam.common = { 'returnmap': '0' }
  543. this.requestParam.data = []
  544. this.requestParam.data[0] = { 'name': 'updateGroups', 'type': 'e', 'parammaps': {
  545. 'id': row.id,
  546. 'groupsname': row.groupsname,
  547. 'groupscode': row.groupscode,
  548. 'emp': row.emp,
  549. 'phone': row.phone,
  550. 'enable': row.enable,
  551. 'note': row.note,
  552. 'user': row.user
  553. }}
  554. this.requestParam.data[1] = { 'name': 'updateUserName', 'type': 'e', 'parammaps': {
  555. 'id': row.id,
  556. 'userold': row.userold,
  557. 'user': row.user
  558. }}
  559. ExecDataByConfig(this.requestParam).then(response => {
  560. console.log('编辑保存发送参数', this.requestParam)
  561. if (response.msg !== 'fail') {
  562. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  563. this.getList()
  564. } else {
  565. const tId = new RegExp("column 'id'")
  566. if (tId.test(response.data)) {
  567. this.$notify({ title: '保存失败', message: '集团已存在,不可重复生成', type: 'warning', duration: 2000 })
  568. } else {
  569. this.$notify({ title: '保存失败', message: response.data, type: 'warning', duration: 2000 })
  570. }
  571. }
  572. })
  573. },
  574. updateCancel(row) {
  575. console.log('点击了编辑取消')
  576. // 编辑false,不可编辑true
  577. row.Edit = false
  578. row.NoEdit = true
  579. // 新增false,编辑true,编辑保存false
  580. row.isCreate = false
  581. row.isUpdate = true
  582. row.isUpdateSave = false
  583. this.getList()
  584. },
  585. handlePageConfiguration(row) {
  586. this.tab1.pageConfiguration.temp = Object.assign({}, row)
  587. console.log('点击了行内页面配置')
  588. this.tab1.pageConfiguration.dialogStatus = 'pageConfiguration'
  589. this.tab1.pageConfiguration.dialogFormVisible = true
  590. this.getPageConfigurationList()
  591. },
  592. getPageConfigurationList() {
  593. this.tab1.pageConfiguration.getdataListParm.parammaps = {}
  594. this.tab1.pageConfiguration.getdataListParm.parammaps.pastureid = this.tab1.pageConfiguration.temp.pastureid
  595. this.tab1.pageConfiguration.getdataListParm.parammaps.id = this.tab1.pageConfiguration.temp.id
  596. this.tab1.pageConfiguration.listLoading = true
  597. GetDataByName(this.tab1.pageConfiguration.getdataListParm).then(response => {
  598. if (response.data.list !== null) {
  599. for (let i = 0; i < response.data.list.length; i++) {
  600. if (parseFloat(response.data.list[i].seebutton) > 0 && response.data.list[i].pid !== -1) {
  601. this.tab1.pageConfiguration.defaultCheckedKeys.push(String(response.data.list[i].menu_id))
  602. }
  603. if (parseFloat(response.data.list[i].seebutton) > 0) {
  604. this.tab1.pageConfiguration.arrList.push(String(response.data.list[i].menu_id))
  605. }
  606. }
  607. this.tab1.pageConfiguration.data = transData(response.data.list, 'id', 'pid', 'children')
  608. console.log(this.tab1.pageConfiguration.data)
  609. console.log(response.data.list)
  610. } else {
  611. this.tab1.pageConfiguration.data = []
  612. }
  613. setTimeout(() => {
  614. this.tab1.pageConfiguration.listLoading = false
  615. }, 1000)
  616. })
  617. },
  618. handelCheckChange(id) {
  619. this.tab1.pageConfiguration.defaultCheckedKeys = this.$refs.tree.getCheckedKeys()
  620. var checkedKeys = this.$refs.tree.getCheckedKeys()
  621. var options = checkedKeys.map((item) => {
  622. var node = this.$refs.tree.getNode(item) // 所有被选中的节点对应的node
  623. const tmpMap = {}
  624. console.log(node, 'node')
  625. tmpMap.pid = node.parent.key
  626. tmpMap.value = node.key
  627. return tmpMap
  628. })
  629. var selectedData = options.map((item) => {
  630. console.log(item)
  631. return item
  632. })
  633. console.log(selectedData)
  634. var arr = []
  635. for (let i = 0; i < selectedData.length; i++) {
  636. if (selectedData[i].pid !== undefined) {
  637. arr.push(selectedData[i].pid, selectedData[i].value)
  638. } else {
  639. arr.push(selectedData[i].value)
  640. }
  641. }
  642. this.tab1.pageConfiguration.arrList = this.unique(arr)
  643. },
  644. unique(arr) {
  645. return Array.from(new Set(arr))
  646. },
  647. pageConfigurationData() {
  648. console.log('集团页面配置保存')
  649. this.isokDisable = true
  650. setTimeout(() => {
  651. this.isokDisable = false
  652. }, 1000)
  653. this.requestParam = {}
  654. this.requestParam.common = { 'returnmap': '0' }
  655. this.requestParam.data = []
  656. this.requestParam.data[0] = { 'name': 'deletemenuPastureJT', 'type': 'e', 'parammaps': {
  657. 'id': this.tab1.pageConfiguration.temp.id
  658. }}
  659. var list = []
  660. for (let i = 0; i < this.tab1.pageConfiguration.arrList.length; i++) {
  661. list.push({ 'id': this.tab1.pageConfiguration.arrList[i] })
  662. }
  663. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': list }}
  664. this.requestParam.data[1].children = []
  665. this.requestParam.data[1].children[0] = { 'name': 'insertRolepastureJT', 'type': 'e', 'parammaps': {
  666. menuid: '@insertSpotList.id',
  667. id: this.tab1.pageConfiguration.temp.id
  668. }}
  669. ExecDataByConfig(this.requestParam).then(response => {
  670. console.log('页面配置保存发送参数', this.requestParam)
  671. if (response.msg !== 'fail') {
  672. this.tab1.pageConfiguration.dialogFormVisible = false
  673. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  674. this.getList()
  675. } else {
  676. failproccess(response, this.$notify)
  677. }
  678. })
  679. },
  680. handleRelation(row) {
  681. this.tab1.relation.temp = Object.assign({}, row)
  682. console.log('关联', this.tab1.relation.temp)
  683. this.tab1.relation.dialogStatus = 'relation'
  684. this.tab1.relation.dialogFormVisible = true
  685. this.tab1.relation.radio = '集团'
  686. this.getGrouplist()
  687. this.getPasturelist()
  688. },
  689. getGrouplist() {
  690. this.tab1.relation.group.table.listLoading = true
  691. this.tab1.relation.group.table.getdataListParm.parammaps.id = this.tab1.relation.temp.id
  692. GetDataByName(this.tab1.relation.group.table.getdataListParm).then(response => {
  693. console.log('集团table数据', response.data.list)
  694. if (response.data.list !== null) {
  695. this.tab1.relation.group.table.list = response.data.list
  696. } else {
  697. this.tab1.relation.group.table.list = []
  698. }
  699. setTimeout(() => {
  700. this.tab1.relation.group.table.listLoading = false
  701. }, 100)
  702. })
  703. },
  704. getPasturelist() {
  705. this.tab1.relation.pasture.table.listLoading = true
  706. this.tab1.relation.pasture.table.getdataListParm.parammaps.id = this.tab1.relation.temp.id
  707. GetDataByName(this.tab1.relation.pasture.table.getdataListParm).then(response => {
  708. console.log('牧场table数据', response.data.list)
  709. if (response.data.list !== null) {
  710. this.tab1.relation.pasture.table.list = response.data.list
  711. } else {
  712. this.tab1.relation.pasture.table.list = []
  713. }
  714. setTimeout(() => {
  715. this.tab1.relation.pasture.table.listLoading = false
  716. }, 100)
  717. })
  718. },
  719. groupSearch(queryString, cb) {
  720. console.log(this.tab1.relation.temp, '====')
  721. this.tab1.relation.group.requestParam.parammaps.groupsname = queryString
  722. this.tab1.relation.group.requestParam.parammaps.id = this.tab1.relation.temp.id
  723. GetDataByName(this.tab1.relation.group.requestParam).then(response => {
  724. if (response.data.list !== null) {
  725. this.tab1.relation.group.searchList = response.data.list
  726. cb(this.tab1.relation.group.searchList)
  727. } else {
  728. cb([])
  729. }
  730. })
  731. },
  732. handleGroupSelect(item) {
  733. if (this.tab1.relation.group.table.list.length > 0) {
  734. if (this.tab1.relation.group.table.list.find(obj => obj.id === item.id)) {
  735. this.$message({ type: 'warning', message: '集团不可重复添加' })
  736. } else {
  737. this.tab1.relation.group.table.list.push(item)
  738. }
  739. } else {
  740. this.tab1.relation.group.table.list.push(item)
  741. }
  742. },
  743. handleGroupDelete(row) {
  744. for (var i = 0; i < this.tab1.relation.group.table.list.length; i++) {
  745. if (this.tab1.relation.group.table.list[i].id == row.id) {
  746. var listIndex = this.tab1.relation.group.table.list.indexOf(this.tab1.relation.group.table.list[i])
  747. }
  748. if (listIndex > -1) {
  749. this.tab1.relation.group.table.list.splice(listIndex, 1)
  750. return
  751. }
  752. }
  753. },
  754. pastureSearch(queryString, cb) {
  755. this.tab1.relation.pasture.requestParam.parammaps.pastureName = queryString
  756. GetDataByName(this.tab1.relation.pasture.requestParam).then(response => {
  757. if (response.data.list !== null) {
  758. this.tab1.relation.pasture.searchList = response.data.list
  759. cb(this.tab1.relation.pasture.searchList)
  760. } else {
  761. cb([])
  762. }
  763. })
  764. },
  765. handlePastureSelect(item) {
  766. if (this.tab1.relation.pasture.table.list.length > 0) {
  767. if (this.tab1.relation.pasture.table.list.find(obj => obj.id === item.id)) {
  768. this.$message({ type: 'warning', message: '集团不可重复添加' })
  769. } else {
  770. this.tab1.relation.pasture.table.list.push(item)
  771. }
  772. } else {
  773. this.tab1.relation.pasture.table.list.push(item)
  774. }
  775. },
  776. handlePastureDelete(row) {
  777. for (var i = 0; i < this.tab1.relation.pasture.table.list.length; i++) {
  778. if (this.tab1.relation.pasture.table.list[i].id == row.id) {
  779. var listIndex = this.tab1.relation.pasture.table.list.indexOf(this.tab1.relation.pasture.table.list[i])
  780. }
  781. if (listIndex > -1) {
  782. this.tab1.relation.pasture.table.list.splice(listIndex, 1)
  783. return
  784. }
  785. }
  786. },
  787. relationData() {
  788. console.log('关联保存')
  789. this.isokDisable = true
  790. setTimeout(() => {
  791. this.isokDisable = false
  792. }, 1000)
  793. this.requestParam = {}
  794. this.requestParam.common = { 'returnmap': '0' }
  795. this.requestParam.data = []
  796. this.requestParam.data[0] = { 'name': 'deletegroupsPasture', 'type': 'e', 'parammaps': {
  797. 'id': this.tab1.relation.temp.id
  798. }}
  799. this.requestParam.data[1] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.tab1.relation.group.table.list }}
  800. this.requestParam.data[1].children = []
  801. this.requestParam.data[1].children[0] = { 'name': 'insertgroupsPasture', 'type': 'e', 'parammaps': {
  802. rid: '@insertSpotList.id',
  803. id: this.tab1.relation.temp.id,
  804. type: '1'
  805. }}
  806. this.requestParam.data[2] = { 'name': 'insertSpotList2', 'resultmaps': { 'list': this.tab1.relation.pasture.table.list }}
  807. this.requestParam.data[2].children = []
  808. this.requestParam.data[2].children[0] = { 'name': 'insertgroupsPasture', 'type': 'e', 'parammaps': {
  809. rid: '@insertSpotList2.id',
  810. id: this.tab1.relation.temp.id,
  811. type: '0'
  812. }}
  813. ExecDataByConfig(this.requestParam).then(response => {
  814. console.log('关联保存发送参数', this.requestParam)
  815. if (response.msg !== 'fail') {
  816. this.tab1.relation.dialogFormVisible = false
  817. this.$notify({ title: '成功', message: '保存成功', type: 'success', duration: 2000 })
  818. this.getList()
  819. } else {
  820. failproccess(response, this.$notify)
  821. }
  822. })
  823. }
  824. }
  825. }
  826. </script>
  827. <style lang="scss" scoped>
  828. .search{margin-top:10px;}
  829. .table{margin-top:10px;}
  830. .inside-base {
  831. position: relative;
  832. }
  833. .inside-base-main {
  834. width: 100%;
  835. background: #ffffff;
  836. box-shadow: 0px 0px 10px 0px rgba(231,232,238,1);
  837. border-radius: 4px;
  838. margin-bottom: 30px;
  839. }
  840. // 中间内容
  841. .inside-base-cont {
  842. margin: 0 20px;
  843. }
  844. .role-cont {
  845. position: relative;
  846. font-size: 16px;
  847. color: #333333;
  848. line-height: 40px;
  849. > span {
  850. width: 90px;
  851. height: 40px;
  852. text-align: right;
  853. float: left;
  854. margin-right: 10px;
  855. margin-bottom: 20px;
  856. }
  857. > div {
  858. position: relative;
  859. width: 100%;
  860. float: left;
  861. margin-bottom: 20px;
  862. >>> .el-input__inner {
  863. width: 320px;
  864. }
  865. }
  866. }
  867. .check-page-all {
  868. position: absolute;
  869. top: 13px;
  870. left: 11px;
  871. z-index: 99;
  872. }
  873. /* element-ui css */
  874. .inside-base {
  875. >>> .el-input__inner {
  876. font-size: 16px;
  877. color: #333333;
  878. }
  879. }
  880. </style>