df31ac124187e2a72cba3e84a174c65abe7c1d26.svn-base 10 KB

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