c47f9216e462dee818f5abb1a0267297197962ef.svn-base 38 KB

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