710afbc5656ee45b6c6dd4c7db4e0a6006cb25d2.svn-base 38 KB

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