a3854111927be28c0d92165773fa8814327d0a45.svn-base 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <div class="app-container">
  3. <div class="operation">
  4. <el-button class="success" @click="handleCreate">新增</el-button>
  5. <el-button class="danger" @click="handleDelete">删除</el-button>
  6. </div>
  7. <div class="search">
  8. <el-input v-model="table.getdataListParm.parammaps.assetCode" placeholder="铲车编号" style="width: 180px;" class="filter-item" />
  9. <el-input v-model="table.getdataListParm.parammaps.assetCode" placeholder="铲车名称" style="width: 180px;" class="filter-item" />
  10. <el-select v-model="table.getdataListParm.parammaps.pastureName" placeholder="是否启用" class="filter-item" style="width: 120px;">
  11. <el-option v-for="item in enableList" :key="item.id" :label="item.name" :value="item.name" />
  12. </el-select>
  13. <el-button class="successBorder" @click="handleSearch">查询</el-button>
  14. <el-button class="successBorder" @click="handleRefresh">重置</el-button>
  15. </div>
  16. <div class="table">
  17. <el-form ref="form" :rules="table.rules" :model="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="110px" align="center">
  39. <template slot-scope="scope">
  40. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  41. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  42. </template>
  43. </el-table-column>
  44. <el-table-column label="铲车名称" min-width="110px" align="center">
  45. <template slot-scope="scope">
  46. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  47. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" maxlength="32" />
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="数据采集卡编号" min-width="110px" align="center">
  51. <template slot-scope="scope">
  52. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  53. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" style="width:80%;padding:10px 0;" />
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="备注" min-width="110px" align="center">
  57. <template slot-scope="scope">
  58. <span v-if="scope.row.NoEdit">{{ scope.row.brandName }}</span>
  59. <el-input v-if="scope.row.Edit" v-model="scope.row.brandName" type="textarea" :autosize="{ minRows: 1.3, maxRows: 4}" style="width:80%;padding:10px 0;" />
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="是否启用" min-width="110px" align="center">
  63. <template slot-scope="scope">
  64. <el-switch v-model="scope.row.enable" :disabled="scope.row.NoEdit==true" active-color="#13ce66" inactive-color="#ff4949" :active-value="1" :inactive-value="0" @change="handleEnableChange(scope.$index, scope.row)" />
  65. </template>
  66. </el-table-column>
  67. <el-table-column label="操作" align="center" width="250" class-name="small-padding fixed-width" fixed="right">
  68. <template slot-scope="{row}">
  69. <!-- 新增 -->
  70. <el-button v-if="row.isCreate" class="miniSuccess" @click="createData(row)">保存</el-button>
  71. <el-button v-if="row.isCreate" type="minCancel" @click="createCancel(row)">取消</el-button>
  72. <!-- 编辑 -->
  73. <el-button v-if="row.isUpdate" class="miniSuccess" @click="handleUpdate(row)">编辑</el-button>
  74. <el-button v-if="row.isUpdate" class="miniDanger" @click="handleRowDelete(row)">删除</el-button>
  75. <!-- 编辑保存 -->
  76. <el-button v-if="row.isUpdateSave" class="miniSuccess" @click="updateData(row)">保存</el-button>
  77. <el-button v-if="row.isUpdateSave" class="minCancel" @click="updateCancel(row)">取消</el-button>
  78. </template>
  79. </el-table-column>
  80. </el-table>
  81. </el-form>
  82. <pagination v-show="table.total>=0" :total="table.total" :page.sync="table.getdataListParm.offset" :limit.sync="table.getdataListParm.pagecount" @pagination="getList" />
  83. </div>
  84. </div>
  85. </template>
  86. <script>
  87. import { GetDataByName } from '@/api/common'
  88. import Pagination from '@/components/Pagination'
  89. export default {
  90. name: 'ForkliftManagement',
  91. components: { Pagination },
  92. data() {
  93. return {
  94. enableList: [{ id: 0, name: '是' }, { id: 1, name: '否' }],
  95. table: {
  96. rules: {
  97. name: { type: 'string', required: true, message: '必填字段', trigger: 'change' }
  98. },
  99. getdataListParm: {
  100. name: 'getAssetList',
  101. page: 1,
  102. offset: 1,
  103. pagecount: 10,
  104. returntype: 'Map',
  105. parammaps: {
  106. eqCode: '',
  107. eqName: '',
  108. status: '',
  109. inputDatetime1: '',
  110. startTime: '',
  111. stopTime: ''
  112. }
  113. },
  114. tableKey: 0,
  115. list: [],
  116. total: 0,
  117. listLoading: true
  118. },
  119. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  120. cellStyle: { padding: 0 + 'px' }
  121. }
  122. },
  123. created() {
  124. this.getList()
  125. },
  126. methods: {
  127. getList() {
  128. this.table.listLoading = true
  129. GetDataByName(this.table.getdataListParm).then(response => {
  130. console.log('table数据', response.data.list)
  131. if (response.data.list !== null) {
  132. for (let i = 0; i < response.data.list.length; i++) {
  133. this.$set(response.data.list[i], 'Edit', false) // 编辑
  134. this.$set(response.data.list[i], 'NoEdit', true) // 不可编辑/输入
  135. this.$set(response.data.list[i], 'isCreate', false) // 新增操作
  136. this.$set(response.data.list[i], 'isUpdate', true) // 编辑操作
  137. this.$set(response.data.list[i], 'isUpdateSave', false) // 编辑保存
  138. }
  139. this.table.list = response.data.list
  140. this.table.pageNum = response.data.pageNum
  141. this.table.pageSize = response.data.pageSize
  142. this.table.total = response.data.total
  143. } else {
  144. this.table.list = []
  145. }
  146. setTimeout(() => {
  147. this.table.listLoading = false
  148. }, 100)
  149. })
  150. },
  151. handleEnableChange() {
  152. console.log('点击了是否启用')
  153. },
  154. handleSearch() {
  155. console.log('点击了查询')
  156. this.getList()
  157. },
  158. handleRefresh() {
  159. console.log('点击了重置')
  160. },
  161. handleSelectionChange(val) {
  162. console.log('勾选数据', val)
  163. },
  164. handleCreate() {
  165. console.log('点击了新增')
  166. // 编辑true/不可编辑false
  167. // 新增操true,编辑false,编辑保存false
  168. for (let i = 0; i < this.table.list.length; i++) {
  169. if (this.table.list[i].Edit == true) {
  170. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  171. return false
  172. }
  173. }
  174. this.table.list.unshift({ 'myId': (new Date()).valueOf(), 'Edit': true, 'NoEdit': false, 'isCreate': true, 'isUpdate': false, 'isUpdateSave': false })
  175. },
  176. createData() {
  177. console.log('点击了新增保存')
  178. },
  179. createCancel(row) {
  180. console.log('点击了新增取消')
  181. for (let i = 0; i < this.table.list.length; i++) {
  182. if (row.myId === this.table.list[i].myId) {
  183. var listIndex = this.table.list.indexOf(this.table.list[i])
  184. }
  185. if (listIndex > -1) {
  186. this.table.list.splice(listIndex, 1)
  187. return
  188. }
  189. }
  190. },
  191. handleUpdate(row) {
  192. for (let i = 0; i < this.table.list.length; i++) {
  193. if (this.table.list[i].Edit == true) {
  194. this.$message({ type: 'error', message: '当前内容未保存,请点击取消或保存继续进行操作', duration: 2000 })
  195. return false
  196. }
  197. }
  198. // 编辑true,不可编辑false
  199. row.Edit = true
  200. row.NoEdit = false
  201. // 新增false,编辑false,编辑保存true
  202. row.isCreate = false
  203. row.isUpdate = false
  204. row.isUpdateSave = true
  205. },
  206. updateData() {
  207. console.log('点击了编辑保存')
  208. },
  209. updateCancel(row) {
  210. console.log('点击了编辑取消')
  211. // 编辑false,不可编辑true
  212. row.Edit = false
  213. row.NoEdit = true
  214. // 新增false,编辑true,编辑保存false
  215. row.isCreate = false
  216. row.isUpdate = true
  217. row.isUpdateSave = false
  218. },
  219. handleRowDelete(row) {
  220. console.log('点击了行内删除')
  221. },
  222. handleDelete() {
  223. console.log('点击了删除')
  224. }
  225. }
  226. }
  227. </script>
  228. <style lang="scss" scoped>
  229. .search{margin-top:10px;}
  230. .table{margin-top:10px;}
  231. </style>