62b702f2ce0bac4be81edfa332e86d6d03d10b95.svn-base 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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;" 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 associatedDevicesList" :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>
  153. </el-dialog>
  154. </div>
  155. </template>
  156. <script>
  157. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
  158. import Cookies from 'js-cookie'
  159. import Pagination from '@/components/Pagination'
  160. import { MessageBox } from 'element-ui'
  161. export default {
  162. name: 'LabelManagement',
  163. components: { Pagination },
  164. data() {
  165. return {
  166. isRoleEdit: [],
  167. labelCategoryList: [], // 标签类别
  168. tagValueList: [], // 标签值
  169. table: {
  170. getdataListParm: {
  171. name: 'getDriverList',
  172. page: 1,
  173. offset: 1,
  174. pagecount: parseInt(Cookies.get('pageCount')),
  175. returntype: 'Map',
  176. parammaps: {
  177. pastureid: Cookies.get('pastureid'),
  178. enable: '',
  179. drivername: '',
  180. drivercode: ''
  181. }
  182. },
  183. tableKey: 0,
  184. list: [],
  185. total: 0,
  186. listLoading: true,
  187. temp: {}
  188. },
  189. dialogStatus: '',
  190. create: {
  191. dialogFormVisible: false,
  192. rules: {},
  193. temp: {},
  194. table: {
  195. getdataListParm: {
  196. name: 'getDriverList', page: 1, offset: 1, pagecount: parseInt(Cookies.get('pageCount')),
  197. returntype: 'Map',
  198. parammaps: { }
  199. },
  200. tableKey: 0,
  201. list: [],
  202. total: 0,
  203. listLoading: false
  204. }
  205. },
  206. textMap: {
  207. create: '新增'
  208. },
  209. requestParam: {},
  210. isokDisable: false,
  211. selectList: [],
  212. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  213. cellStyle: { padding: 0 + 'px' }
  214. }
  215. },
  216. created() {
  217. this.getList()
  218. this.getButtons()
  219. },
  220. methods: {
  221. getButtons() {
  222. const Edit = 'Driver'
  223. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  224. this.isRoleEdit = isRoleEdit
  225. },
  226. getList() {
  227. this.table.listLoading = true
  228. GetDataByName(this.table.getdataListParm).then(response => {
  229. console.log('table数据', response.data.list)
  230. if (response.data.list !== null) {
  231. this.table.list = response.data.list
  232. this.table.pageNum = response.data.pageNum
  233. this.table.pageSize = response.data.pageSize
  234. this.table.total = response.data.total
  235. } else {
  236. this.table.list = []
  237. }
  238. setTimeout(() => {
  239. this.table.listLoading = false
  240. }, 100)
  241. })
  242. },
  243. handleEnableChange() {
  244. console.log('点击了是否启用')
  245. },
  246. handleSearch() {
  247. console.log('点击了查询')
  248. this.table.getdataListParm.offset = 1
  249. this.getList()
  250. },
  251. handleRefresh() {
  252. console.log('点击了重置')
  253. this.table.getdataListParm.parammaps.drivername = ''
  254. this.table.getdataListParm.parammaps.enable = ''
  255. this.table.getdataListParm.parammaps.drivercode = ''
  256. this.table.getdataListParm.offset = 1
  257. this.getList()
  258. },
  259. handleCreate() {
  260. console.log('新增')
  261. // this.create.temp = Object.assign({}, row)
  262. this.dialogStatus = 'create'
  263. this.create.dialogFormVisible = true
  264. },
  265. handleNewLabelValue() {
  266. console.log('新增标签值')
  267. for (let i = 0; i < this.create.table.list.length; i++) {
  268. if (this.create.table.list[i].Edit == true) {
  269. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  270. return false
  271. }
  272. }
  273. 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': '' })
  274. },
  275. NewLabelcreateData() {
  276. console.log('点击了新增标签新增保存')
  277. },
  278. createNewLabelCancel(row) {
  279. console.log('点击了新增标签新增取消')
  280. for (let i = 0; i < this.create.table.list.length; i++) {
  281. if (row.myId === this.create.table.list[i].myId) {
  282. var listIndex = this.create.table.list.indexOf(this.create.table.list[i])
  283. }
  284. if (listIndex > -1) {
  285. this.create.table.list.splice(listIndex, 1)
  286. return
  287. }
  288. }
  289. },
  290. handleNewLabelUpdate(row) {
  291. for (let i = 0; i < this.create.table.list.length; i++) {
  292. if (this.create.table.list[i].Edit == true) {
  293. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  294. return false
  295. }
  296. }
  297. // 编辑true,不可编辑false
  298. row.Edit = true
  299. row.NoEdit = false
  300. // 新增false,编辑false,编辑保存true
  301. row.isCreate = false
  302. row.isUpdate = false
  303. row.isUpdateSave = true
  304. },
  305. handleNewLabelRowDelete() {
  306. console.log('点击了新增标签编辑删除')
  307. },
  308. NewLabelupdateData() {
  309. console.log('点击了新增标签编辑保存')
  310. },
  311. NewLabelupdateCancel(row) {
  312. console.log('点击了编辑取消')
  313. // 编辑false,不可编辑true
  314. row.Edit = false
  315. row.NoEdit = true
  316. // 新增false,编辑true,编辑保存false
  317. row.isCreate = false
  318. row.isUpdate = true
  319. row.isUpdateSave = false
  320. },
  321. handleUpdate(row) {
  322. console.log('编辑')
  323. },
  324. handleRowDelete(row) {
  325. console.log('点击了行内删除')
  326. MessageBox.confirm('是否确认删除此信息?', {
  327. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  328. }).then(() => {
  329. this.selectList = []
  330. this.requestParam.name = 'deleteDriver'
  331. this.requestParam.parammaps = {}
  332. this.requestParam.parammaps.pastureid = row.pastureid
  333. this.requestParam.parammaps.id = row.id
  334. PostDataByName(this.requestParam).then(response => {
  335. if (response.msg === 'fail') {
  336. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  337. } else {
  338. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  339. this.getList()
  340. }
  341. })
  342. }).catch(() => {
  343. this.$message({ type: 'info', message: '已取消删除' })
  344. })
  345. },
  346. handleSelectionChange(val) {
  347. console.log('勾选数据', val)
  348. this.selectList = val
  349. },
  350. handleDelete() {
  351. console.log('点击了删除')
  352. if (this.selectList.length == 0) {
  353. this.$message({ type: 'error', message: '请选择驾驶员信息', duration: 2000 })
  354. } else {
  355. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  356. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  357. }).then(() => {
  358. console.log(this.selectList)
  359. this.requestParam.common = { 'returnmap': '0' }
  360. this.requestParam.data = []
  361. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  362. this.requestParam.data[0].children = []
  363. this.requestParam.data[0].children[0] = { 'name': 'deleteDriver', 'type': 'e', 'parammaps': {
  364. id: '@insertSpotList.id',
  365. pastureid: '@insertSpotList.pastureid'
  366. }}
  367. ExecDataByConfig(this.requestParam).then(response => {
  368. console.log('删除保存发送参数', this.requestParam)
  369. if (response.msg === 'fail') {
  370. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  371. } else {
  372. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  373. this.getList()
  374. }
  375. })
  376. })
  377. }
  378. }
  379. }
  380. }
  381. </script>
  382. <style lang="scss" scoped>
  383. .search{margin-top:10px;}
  384. .table{margin-top:10px;}
  385. </style>