97b3616ef9f58c40ea41faf0a03d6eb0fc937e18.svn-base 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. <template>
  2. <div class="app-container">
  3. <div class="search">
  4. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="标签类别" class="filter-item" style="width: 120px;" clearable>
  5. <el-option v-for="item in labelCategoryList" :key="item.id" :label="item.name" :value="item.id" />
  6. </el-select>
  7. <el-select v-model="table.getdataListParm.parammaps.enable" filterable placeholder="标签值" class="filter-item" style="width: 120px;" clearable>
  8. <el-option v-for="item in tagValueList" :key="item.id" :label="item.name" :value="item.id" />
  9. </el-select>
  10. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  11. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  12. </div>
  13. <div class="operation">
  14. <el-button v-if="isRoleEdit" class="success" icon="el-icon-plus" @click="handleCreate">新增</el-button>
  15. <el-button v-if="isRoleEdit" class="danger" icon="el-icon-delete" @click="handleDelete">删除</el-button>
  16. </div>
  17. <div class="table">
  18. <el-table
  19. :key="table.tableKey"
  20. v-loading="table.listLoading"
  21. element-loading-text="给我一点时间"
  22. :data="table.list"
  23. border
  24. fit
  25. highlight-current-row
  26. style="width: 100%;"
  27. :row-style="rowStyle"
  28. :cell-style="cellStyle"
  29. class="elTable table-fixed"
  30. @selection-change="handleSelectionChange"
  31. >
  32. <el-table-column type="selection" align="center" width="50" />
  33. <el-table-column label="序号" align="center" type="index" width="50px">
  34. <template slot-scope="scope">
  35. <span>{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  36. </template>
  37. </el-table-column>
  38. <el-table-column label="标签类别" min-width="130px" align="center">
  39. <template slot-scope="scope">
  40. <span>{{ scope.row.drivercode }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="标签值" min-width="130px" align="center">
  44. <template slot-scope="scope">
  45. <span>{{ scope.row.drivername }}</span>
  46. </template>
  47. </el-table-column>
  48. <el-table-column label="备注" min-width="130px" align="center">
  49. <template slot-scope="scope">
  50. <span>{{ scope.row.drivername }}</span>
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="创建人" min-width="130px" align="center">
  54. <template slot-scope="scope">
  55. <span>{{ scope.row.drivername }}</span>
  56. </template>
  57. </el-table-column>
  58. <el-table-column label="创建时间" min-width="130px" align="center">
  59. <template slot-scope="scope">
  60. <span>{{ scope.row.drivername }}</span>
  61. </template>
  62. </el-table-column>
  63. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  64. <template slot-scope="{row}">
  65. <!-- 编辑 -->
  66. <el-button class="miniSuccess" icon="el-icon-edit-outline" @click="handleUpdate(row)" />
  67. <span class="centerSpan">|</span>
  68. <el-button class="miniDanger" icon="el-icon-delete" @click="handleRowDelete(row)" />
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. <pagination v-show="table.total>0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  73. </div>
  74. <el-dialog :title="textMap[dialogStatus]" :visible.sync="create.dialogFormVisible" :close-on-click-modal="false" width="70%">
  75. <div class="create">
  76. <el-form ref="temp" :rules="create.rules" :model="create.temp" label-position="right" label-width="155px" style="width: 100%;margin:0 auto 50px">
  77. <el-row>
  78. <el-col :span="10">
  79. <el-form-item label="标签类别:" prop="fname">
  80. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入标签类别" type="text" />
  81. </el-form-item>
  82. </el-col>
  83. </el-row>
  84. <el-row>
  85. <el-col :span="10">
  86. <el-form-item label="备注:" prop="fname">
  87. <el-input ref="fname" v-model="create.temp.fname" class="filter-item" placeholder="请输入备注" type="text" />
  88. </el-form-item>
  89. </el-col>
  90. </el-row>
  91. <div style="width: 155px;">
  92. <el-button style="float: right;margin-bottom: 10px;" icon="el-icon-plus" class="success" @click="handleNewLabelValue">新增标签值</el-button>
  93. </div>
  94. <el-table
  95. :key="create.table.tableKey"
  96. v-loading="create.table.listLoading"
  97. element-loading-text="给我一点时间"
  98. :data="create.table.list"
  99. border
  100. fit
  101. highlight-current-row
  102. style="width: 100%;"
  103. :row-style="rowStyle"
  104. :cell-style="cellStyle"
  105. class="elTable table-fixed"
  106. >
  107. <el-table-column type="selection" align="center" width="50" />
  108. <el-table-column label="序号" align="center" type="index" width="50px">
  109. <template slot-scope="scope">
  110. <span v-if="create.table.pageNum">{{ scope.$index + (table.pageNum-1) * table.pageSize + 1 }}</span>
  111. <span v-else>1</span>
  112. </template>
  113. </el-table-column>
  114. <el-table-column label="标签值" min-width="110px" align="center">
  115. <template slot-scope="scope">
  116. <span v-if="scope.row.NoEdit">{{ scope.row.gpsCode }}</span>
  117. <el-input v-if="scope.row.Edit" v-model="scope.row.gpsCode" placeholder="标签值" style="width:80%;padding:10px 0;" />
  118. </template>
  119. </el-table-column>
  120. <el-table-column label="标签说明" min-width="110px" align="center">
  121. <template slot-scope="scope">
  122. <span v-if="scope.row.NoEdit">{{ scope.row.gpsName }}</span>
  123. <el-input v-if="scope.row.Edit" v-model="scope.row.gpsName" placeholder="标签说明" style="width:80%;padding:10px 0;" />
  124. </template>
  125. </el-table-column>
  126. <el-table-column label="标签牧场" min-width="110px" align="center">
  127. <template slot-scope="scope">
  128. <span v-if="scope.row.NoEdit">{{ scope.row.tname }}</span>
  129. <el-select v-if="scope.row.Edit" v-model="scope.row.tmrId" @change="(value)=> {handleAssociatedDevicesChange(value,scope.row)}">
  130. <el-option v-for="item in labelRanchList" :key="item.id" :label="`名称:${item.tname} 编号:${item.eqcode}类型:${item.tclassname}`" :value="item.id" />
  131. </el-select>
  132. </template>
  133. </el-table-column>
  134. <el-table-column label="操作" align="center" width="80" class-name="small-padding fixed-width" fixed="right">
  135. <template slot-scope="{row}">
  136. <!-- 新增 -->
  137. <el-button v-if="row.isCreate" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="NewLabelcreateData(row)" />
  138. <span v-if="row.isCreate" class="centerSpan">|</span>
  139. <el-button v-if="row.isCreate" class="minCancel" icon="el-icon-close" @click="createNewLabelCancel(row)" />
  140. <!-- 编辑 -->
  141. <el-button v-if="row.isUpdate && isRoleEdit" class="miniSuccess" icon="el-icon-edit-outline" @click="handleNewLabelUpdate(row)" />
  142. <span v-if="row.isUpdate && isRoleEdit" class="centerSpan">|</span>
  143. <el-button v-if="row.isUpdate && isRoleEdit" class="miniDanger" icon="el-icon-delete" @click="handleNewLabelRowDelete(row)" />
  144. <!-- 编辑保存 -->
  145. <el-button v-if="row.isUpdateSave" :disabled="isokDisable" icon="el-icon-folder-checked" class="miniSuccess" @click="NewLabelupdateData(row)" />
  146. <span v-if="row.isUpdateSave" class="centerSpan">|</span>
  147. <el-button v-if="row.isUpdateSave" class="minCancel" icon="el-icon-close" @click="NewLabelupdateCancel(row)" />
  148. </template>
  149. </el-table-column>
  150. </el-table>
  151. </el-form>
  152. <div slot="footer" class="dialog-footer" style="bottom: 10px;">
  153. <el-button class="cancelClose" @click="create.dialogFormVisible = false; ">关闭</el-button>
  154. <el-button class="save" :disabled="isokDisable" @click="createData()">确认</el-button>
  155. </div>
  156. </div>
  157. </el-dialog>
  158. </div>
  159. </template>
  160. <script>
  161. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
  162. import Cookies from 'js-cookie'
  163. import Pagination from '@/components/Pagination'
  164. import { MessageBox } from 'element-ui'
  165. export default {
  166. name: 'LabelManagement',
  167. components: { Pagination },
  168. data() {
  169. return {
  170. labelRanchList: [],
  171. isRoleEdit: [],
  172. labelCategoryList: [], // 标签类别
  173. tagValueList: [], // 标签值
  174. table: {
  175. getdataListParm: {
  176. name: 'getDriverList',
  177. page: 1,
  178. offset: 1,
  179. pagecount: parseInt(Cookies.get('pageCount')),
  180. returntype: 'Map',
  181. parammaps: {
  182. pastureid: Cookies.get('pastureid'),
  183. enable: '',
  184. drivername: '',
  185. drivercode: ''
  186. }
  187. },
  188. tableKey: 0,
  189. list: [],
  190. total: 0,
  191. listLoading: true,
  192. temp: {}
  193. },
  194. dialogStatus: '',
  195. create: {
  196. dialogFormVisible: false,
  197. rules: {},
  198. temp: {},
  199. table: {
  200. getdataListParm: {
  201. name: 'getDriverList', page: 1, offset: 1, pagecount: parseInt(Cookies.get('pageCount')),
  202. returntype: 'Map',
  203. parammaps: { }
  204. },
  205. tableKey: 0,
  206. list: [],
  207. total: 0,
  208. listLoading: false
  209. }
  210. },
  211. textMap: {
  212. create: '新增'
  213. },
  214. requestParam: {},
  215. isokDisable: false,
  216. selectList: [],
  217. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  218. cellStyle: { padding: 0 + 'px' }
  219. }
  220. },
  221. created() {
  222. this.getList()
  223. this.getButtons()
  224. },
  225. methods: {
  226. getButtons() {
  227. const Edit = 'Driver'
  228. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  229. this.isRoleEdit = isRoleEdit
  230. },
  231. getList() {
  232. this.table.listLoading = true
  233. GetDataByName(this.table.getdataListParm).then(response => {
  234. console.log('table数据', response.data.list)
  235. if (response.data.list !== null) {
  236. this.table.list = response.data.list
  237. this.table.pageNum = response.data.pageNum
  238. this.table.pageSize = response.data.pageSize
  239. this.table.total = response.data.total
  240. } else {
  241. this.table.list = []
  242. }
  243. setTimeout(() => {
  244. this.table.listLoading = false
  245. }, 100)
  246. })
  247. },
  248. handleEnableChange() {
  249. console.log('点击了是否启用')
  250. },
  251. handleSearch() {
  252. console.log('点击了查询')
  253. this.table.getdataListParm.offset = 1
  254. this.getList()
  255. },
  256. handleRefresh() {
  257. console.log('点击了重置')
  258. this.table.getdataListParm.parammaps.drivername = ''
  259. this.table.getdataListParm.parammaps.enable = ''
  260. this.table.getdataListParm.parammaps.drivercode = ''
  261. this.table.getdataListParm.offset = 1
  262. this.getList()
  263. },
  264. handleCreate() {
  265. console.log('新增')
  266. // this.create.temp = Object.assign({}, row)
  267. this.dialogStatus = 'create'
  268. this.create.dialogFormVisible = true
  269. },
  270. handleNewLabelValue() {
  271. console.log('新增标签值')
  272. for (let i = 0; i < this.create.table.list.length; i++) {
  273. if (this.create.table.list[i].Edit == true) {
  274. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  275. return false
  276. }
  277. }
  278. this.create.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false, 'enable': 1, 'gpsCode': '', 'gpsName': '', 'tmrId': '', 'remark': '' })
  279. },
  280. NewLabelcreateData() {
  281. console.log('点击了新增标签新增保存')
  282. },
  283. createData() {
  284. console.log('点击了新增保存')
  285. },
  286. createNewLabelCancel(row) {
  287. console.log('点击了新增标签新增取消')
  288. for (let i = 0; i < this.create.table.list.length; i++) {
  289. if (row.myId === this.create.table.list[i].myId) {
  290. var listIndex = this.create.table.list.indexOf(this.create.table.list[i])
  291. }
  292. if (listIndex > -1) {
  293. this.create.table.list.splice(listIndex, 1)
  294. return
  295. }
  296. }
  297. },
  298. handleNewLabelUpdate(row) {
  299. for (let i = 0; i < this.create.table.list.length; i++) {
  300. if (this.create.table.list[i].Edit == true) {
  301. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  302. return false
  303. }
  304. }
  305. // 编辑true,不可编辑false
  306. row.Edit = true
  307. row.NoEdit = false
  308. // 新增false,编辑false,编辑保存true
  309. row.isCreate = false
  310. row.isUpdate = false
  311. row.isUpdateSave = true
  312. },
  313. handleNewLabelRowDelete() {
  314. console.log('点击了新增标签编辑删除')
  315. },
  316. NewLabelupdateData() {
  317. console.log('点击了新增标签编辑保存')
  318. },
  319. NewLabelupdateCancel(row) {
  320. console.log('点击了编辑取消')
  321. // 编辑false,不可编辑true
  322. row.Edit = false
  323. row.NoEdit = true
  324. // 新增false,编辑true,编辑保存false
  325. row.isCreate = false
  326. row.isUpdate = true
  327. row.isUpdateSave = false
  328. },
  329. handleUpdate(row) {
  330. console.log('编辑')
  331. },
  332. handleRowDelete(row) {
  333. console.log('点击了行内删除')
  334. MessageBox.confirm('是否确认删除此信息?', {
  335. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  336. }).then(() => {
  337. this.selectList = []
  338. this.requestParam.name = 'deleteDriver'
  339. this.requestParam.parammaps = {}
  340. this.requestParam.parammaps.pastureid = row.pastureid
  341. this.requestParam.parammaps.id = row.id
  342. PostDataByName(this.requestParam).then(response => {
  343. if (response.msg === 'fail') {
  344. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  345. } else {
  346. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  347. this.getList()
  348. }
  349. })
  350. }).catch(() => {
  351. this.$message({ type: 'info', message: '已取消删除' })
  352. })
  353. },
  354. handleSelectionChange(val) {
  355. console.log('勾选数据', val)
  356. this.selectList = val
  357. },
  358. handleDelete() {
  359. console.log('点击了删除')
  360. if (this.selectList.length == 0) {
  361. this.$message({ type: 'error', message: '请选择驾驶员信息', duration: 2000 })
  362. } else {
  363. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  364. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  365. }).then(() => {
  366. console.log(this.selectList)
  367. this.requestParam.common = { 'returnmap': '0' }
  368. this.requestParam.data = []
  369. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  370. this.requestParam.data[0].children = []
  371. this.requestParam.data[0].children[0] = { 'name': 'deleteDriver', 'type': 'e', 'parammaps': {
  372. id: '@insertSpotList.id',
  373. pastureid: '@insertSpotList.pastureid'
  374. }}
  375. ExecDataByConfig(this.requestParam).then(response => {
  376. console.log('删除保存发送参数', this.requestParam)
  377. if (response.msg === 'fail') {
  378. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  379. } else {
  380. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  381. this.getList()
  382. }
  383. })
  384. })
  385. }
  386. }
  387. }
  388. }
  389. </script>
  390. <style lang="scss" scoped>
  391. .search{margin-top:10px;}
  392. .table{margin-top:10px;}
  393. </style>