49b46a0778a8245a70cd69375b825952d36d358f.svn-base 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  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;" class="success" @click="handleNewLabelValue">新增标签值</el-button>
  93. </div>
  94. </el-form>
  95. </div>
  96. </el-dialog>
  97. </div>
  98. </template>
  99. <script>
  100. import { GetDataByName, PostDataByName, failproccess, ExecDataByConfig, checkButtons } from '@/api/common'
  101. import Cookies from 'js-cookie'
  102. import Pagination from '@/components/Pagination'
  103. import { MessageBox } from 'element-ui'
  104. export default {
  105. name: 'LabelManagement',
  106. components: { Pagination },
  107. data() {
  108. return {
  109. isRoleEdit: [],
  110. labelCategoryList: [], // 标签类别
  111. tagValueList: [], // 标签值
  112. table: {
  113. getdataListParm: {
  114. name: 'getDriverList',
  115. page: 1,
  116. offset: 1,
  117. pagecount: 10,
  118. returntype: 'Map',
  119. parammaps: {
  120. pastureid: Cookies.get('pastureid'),
  121. enable: '',
  122. drivername: '',
  123. drivercode: ''
  124. }
  125. },
  126. tableKey: 0,
  127. list: [],
  128. total: 0,
  129. listLoading: true,
  130. temp: {}
  131. },
  132. dialogStatus: '',
  133. create: {
  134. dialogFormVisible: false,
  135. rules: {},
  136. temp: {}
  137. },
  138. textMap: {
  139. create: '新增'
  140. },
  141. requestParam: {},
  142. isokDisable: false,
  143. selectList: [],
  144. rowStyle: { maxHeight: 30 + 'px', height: 30 + 'px' },
  145. cellStyle: { padding: 0 + 'px' }
  146. }
  147. },
  148. created() {
  149. this.getList()
  150. this.getButtons()
  151. },
  152. methods: {
  153. getButtons() {
  154. const Edit = 'Driver'
  155. const isRoleEdit = checkButtons(JSON.parse(sessionStorage.getItem('buttons')), Edit)
  156. this.isRoleEdit = isRoleEdit
  157. },
  158. getList() {
  159. this.table.listLoading = true
  160. GetDataByName(this.table.getdataListParm).then(response => {
  161. console.log('table数据', response.data.list)
  162. if (response.data.list !== null) {
  163. this.table.list = response.data.list
  164. this.table.pageNum = response.data.pageNum
  165. this.table.pageSize = response.data.pageSize
  166. this.table.total = response.data.total
  167. } else {
  168. this.table.list = []
  169. }
  170. setTimeout(() => {
  171. this.table.listLoading = false
  172. }, 100)
  173. })
  174. },
  175. handleEnableChange() {
  176. console.log('点击了是否启用')
  177. },
  178. handleSearch() {
  179. console.log('点击了查询')
  180. this.table.getdataListParm.offset = 1
  181. this.getList()
  182. },
  183. handleRefresh() {
  184. console.log('点击了重置')
  185. this.table.getdataListParm.parammaps.drivername = ''
  186. this.table.getdataListParm.parammaps.enable = ''
  187. this.table.getdataListParm.parammaps.drivercode = ''
  188. this.table.getdataListParm.offset = 1
  189. this.getList()
  190. },
  191. handleCreate() {
  192. console.log('新增')
  193. // this.create.temp = Object.assign({}, row)
  194. this.dialogStatus = 'create'
  195. this.create.dialogFormVisible = true
  196. },
  197. handleNewLabelValue() {
  198. console.log('新增标签值')
  199. },
  200. handleUpdate(row) {
  201. console.log('编辑')
  202. },
  203. handleRowDelete(row) {
  204. console.log('点击了行内删除')
  205. MessageBox.confirm('是否确认删除此信息?', {
  206. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  207. }).then(() => {
  208. this.selectList = []
  209. this.requestParam.name = 'deleteDriver'
  210. this.requestParam.parammaps = {}
  211. this.requestParam.parammaps.pastureid = row.pastureid
  212. this.requestParam.parammaps.id = row.id
  213. PostDataByName(this.requestParam).then(response => {
  214. if (response.msg === 'fail') {
  215. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  216. } else {
  217. this.$notify({ title: '成功', message: '删除成功', type: 'success', duration: 2000 })
  218. this.getList()
  219. }
  220. })
  221. }).catch(() => {
  222. this.$message({ type: 'info', message: '已取消删除' })
  223. })
  224. },
  225. handleSelectionChange(val) {
  226. console.log('勾选数据', val)
  227. this.selectList = val
  228. },
  229. handleDelete() {
  230. console.log('点击了删除')
  231. if (this.selectList.length == 0) {
  232. this.$message({ type: 'error', message: '请选择驾驶员信息', duration: 2000 })
  233. } else {
  234. MessageBox.confirm('当前选中' + this.selectList.length + '条信息,是否删除?', {
  235. confirmButtonText: '确认', cancelButtonText: '取消', type: 'warning'
  236. }).then(() => {
  237. console.log(this.selectList)
  238. this.requestParam.common = { 'returnmap': '0' }
  239. this.requestParam.data = []
  240. this.requestParam.data[0] = { 'name': 'insertSpotList', 'resultmaps': { 'list': this.selectList }}
  241. this.requestParam.data[0].children = []
  242. this.requestParam.data[0].children[0] = { 'name': 'deleteDriver', 'type': 'e', 'parammaps': {
  243. id: '@insertSpotList.id',
  244. pastureid: '@insertSpotList.pastureid'
  245. }}
  246. ExecDataByConfig(this.requestParam).then(response => {
  247. console.log('删除保存发送参数', this.requestParam)
  248. if (response.msg === 'fail') {
  249. this.$notify({ title: '删除失败', message: response.data, type: 'warning', duration: 2000 })
  250. } else {
  251. this.$notify({ title: '', message: '删除成功', type: 'success', duration: 2000 })
  252. this.getList()
  253. }
  254. })
  255. })
  256. }
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .search{margin-top:10px;}
  263. .table{margin-top:10px;}
  264. </style>