express.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  1. rookieCode<template>
  2. <div class="app-container calendar-list-container">
  3. <!-- 查询和其他操作 -->
  4. <div class="filter-container">
  5. <el-input clearable class="filter-item" style="width: 200px;" placeholder="物流公司名称" v-model="listQuery.logisticsName">
  6. </el-input>
  7. <el-select v-model="listQuery.status" clearable placeholder="状态" class="filter-item" style="width: 200px;">
  8. <el-option :key="item.type" v-for="item in statusList" :label="item.name" :value="item.type">
  9. </el-option>
  10. </el-select>
  11. <el-button class="filter-item" type="primary" v-waves icon="el-icon-search" @click="handleQuery">查找</el-button>
  12. <el-button class="filter-item" icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  13. <el-button class="filter-item" type="primary" icon="el-icon-plus" @click="handleCreate">添加</el-button>
  14. <!-- <el-button class="filter-item" v-waves icon="el-icon-download" @click="handleDownload">导出</el-button> -->
  15. </div>
  16. <!-- 查询结果 -->
  17. <el-table size="small" :data="list" v-loading="listLoading" element-loading-text="正在查询中。。。" border fit
  18. highlight-current-row>
  19. <el-table-column type="index" label="序号" header-align="center" align="center">
  20. </el-table-column>
  21. <el-table-column align="center" min-width="100px" label="物流公司名称" prop="logisticsName">
  22. </el-table-column>
  23. <el-table-column align="center" min-width="80px" label="快递查询代码" prop="queryCode">
  24. </el-table-column>
  25. <el-table-column align="center" min-width="80px" label="菜鸟代码" prop="rookieCode">
  26. </el-table-column>
  27. <el-table-column align="center" min-width="50px" label="状态">
  28. <template slot-scope="props">
  29. <span v-if="props.row.status == 0" style="color: #67C23A;font-weight: bold;">启用</span>
  30. <span v-if="props.row.status == 1" style="color: #E6A23C;font-weight: bold;">停用</span>
  31. </template>
  32. </el-table-column>
  33. <!-- <el-table-column align="center" min-width="150px" label="备注" prop="remarks">
  34. </el-table-column> -->
  35. <el-table-column align="center" label="操作" width="250" class-name="small-padding fixed-width">
  36. <template slot-scope="scope">
  37. <el-button type="primary" size="small" @click="handleUpdate(scope.row)">编辑</el-button>
  38. <el-button v-if="scope.row.status == 1" type="success" size="small"
  39. @click="changeState(scope.row.id, scope.row.status)">启用</el-button>
  40. <el-button v-if="scope.row.status == 0" type="warning" size="small"
  41. @click="changeState(scope.row.id, scope.row.status)">停用</el-button>
  42. <el-button type="danger" size="small" @click="handleDelete(scope.row)">删除</el-button>
  43. </template>
  44. </el-table-column>
  45. </el-table>
  46. <!-- 分页 -->
  47. <div class="pagination-container">
  48. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  49. :current-page="listQuery.page" :page-sizes="[10, 20, 30, 50]" :page-size="listQuery.limit"
  50. layout="total, sizes, prev, pager, next, jumper" :total="total">
  51. </el-pagination>
  52. </div>
  53. <!-- 添加或修改对话框 -->
  54. <el-dialog :title="textMap[dialogStatus]" :visible.sync="dialogFormVisible" width="600px">
  55. <el-form :rules="rules" ref="dataForm" :model="dataForm" status-icon label-position="left" label-width="110px">
  56. <el-form-item label="物流公司名称" prop="logisticsName">
  57. <el-input v-model="dataForm.logisticsName"></el-input>
  58. </el-form-item>
  59. <el-form-item label="快递查询代码" prop="queryCode">
  60. <el-input v-model="dataForm.queryCode"></el-input>
  61. </el-form-item>
  62. <el-form-item label="菜鸟代码" prop="rookieCode">
  63. <el-input v-model="dataForm.rookieCode"></el-input>
  64. </el-form-item>
  65. <!-- <el-form-item label="备注" prop="remarks">
  66. <el-input type="textarea" :autosize="{ minRows: 2, maxRows: 4 }" placeholder="请输入"
  67. v-model="dataForm.remarks">
  68. </el-input>
  69. </el-form-item> -->
  70. </el-form>
  71. <div slot="footer" class="dialog-footer">
  72. <el-button @click="dialogFormVisible = false">取消</el-button>
  73. <el-button v-if="dialogStatus == 'create'" type="primary" @click="createData">确定</el-button>
  74. <el-button v-else type="primary" @click="updateData">确定</el-button>
  75. </div>
  76. </el-dialog>
  77. </div>
  78. </template>
  79. <script>
  80. import { listExpress, createExpress, updateExpress, deleteExpress, setState } from '@/api/express'
  81. import waves from '@/directive/waves' // 水波纹指令
  82. export default {
  83. directives: { waves },
  84. data() {
  85. return {
  86. list: undefined,
  87. total: undefined,
  88. listLoading: true,
  89. statusList: [
  90. {
  91. type: 0,
  92. name: '启用'
  93. },
  94. {
  95. type: 1,
  96. name: '停用'
  97. },
  98. ],
  99. listQuery: {
  100. page: 1,
  101. limit: 10,
  102. logisticsName: undefined,
  103. status: undefined,
  104. },
  105. dataForm: {
  106. logisticsName: undefined,
  107. queryCode: undefined,
  108. rookieCode: undefined,
  109. remarks: undefined,
  110. },
  111. dialogFormVisible: false,
  112. dialogStatus: '',
  113. textMap: {
  114. update: '编辑',
  115. create: '创建'
  116. },
  117. rules: {
  118. logisticsName: [{ required: true, message: '物流公司名称不能为空', trigger: 'blur' }],
  119. queryCode: [{ required: true, message: '快递查询代码不能为空', trigger: 'blur' }],
  120. rookieCode: [{ required: true, message: '菜鸟代码不能为空', trigger: 'blur' }],
  121. },
  122. }
  123. },
  124. created() {
  125. this.getList()
  126. },
  127. methods: {
  128. /** 重置按钮操作 */
  129. resetQuery() {
  130. this.listQuery = {
  131. page: 1,
  132. limit: 10,
  133. logisticsName: undefined,
  134. status: undefined,
  135. };
  136. this.handleQuery();
  137. },
  138. getList() {
  139. this.listLoading = true
  140. listExpress(this.listQuery).then(response => {
  141. this.list = response.data.data.items
  142. this.total = response.data.data.total
  143. this.listLoading = false
  144. }).catch(() => {
  145. this.list = []
  146. this.total = 0
  147. this.listLoading = false
  148. })
  149. },
  150. handleQuery() {
  151. this.listQuery.page = 1
  152. this.getList()
  153. },
  154. handleSizeChange(val) {
  155. this.listQuery.limit = val
  156. this.getList()
  157. },
  158. handleCurrentChange(val) {
  159. this.listQuery.page = val
  160. this.getList()
  161. },
  162. resetForm() {
  163. this.dataForm = {
  164. logisticsName: undefined,
  165. queryCode: undefined,
  166. rookieCode: undefined,
  167. remarks: undefined,
  168. }
  169. },
  170. handleCreate() {
  171. this.resetForm()
  172. this.dialogStatus = 'create'
  173. this.dialogFormVisible = true
  174. this.$nextTick(() => {
  175. this.$refs['dataForm'].clearValidate()
  176. })
  177. },
  178. createData() {
  179. this.$refs['dataForm'].validate((valid) => {
  180. if (valid) {
  181. createExpress(this.dataForm).then(response => {
  182. this.list.unshift(response.data.data)
  183. this.dialogFormVisible = false
  184. this.$notify({
  185. title: '成功',
  186. message: '创建成功',
  187. type: 'success',
  188. duration: 2000
  189. })
  190. this.getList()
  191. })
  192. }
  193. })
  194. },
  195. handleUpdate(row) {
  196. this.dataForm = Object.assign({}, row)
  197. this.dialogStatus = 'update'
  198. this.dialogFormVisible = true
  199. this.$nextTick(() => {
  200. this.$refs['dataForm'].clearValidate()
  201. })
  202. },
  203. updateData() {
  204. this.$refs['dataForm'].validate((valid) => {
  205. if (valid) {
  206. updateExpress(this.dataForm).then(() => {
  207. for (const v of this.list) {
  208. if (v.id === this.dataForm.id) {
  209. const index = this.list.indexOf(v)
  210. this.list.splice(index, 1, this.dataForm)
  211. break
  212. }
  213. }
  214. this.dialogFormVisible = false
  215. this.$notify({
  216. title: '成功',
  217. message: '更新成功',
  218. type: 'success',
  219. duration: 2000
  220. })
  221. this.getList()
  222. })
  223. }
  224. })
  225. },
  226. handleDelete(row) {
  227. this.$confirm('确认删除吗?', '提示', {
  228. confirmButtonText: '确定',
  229. cancelButtonText: '取消',
  230. type: 'warning'
  231. }).then(() => {
  232. deleteExpress({id:row.id}).then(response => {
  233. this.$notify({
  234. title: '成功',
  235. message: '删除成功',
  236. type: 'success',
  237. duration: 2000
  238. })
  239. this.getList()
  240. })
  241. }).catch(() => {
  242. })
  243. },
  244. handleDownload() {
  245. window.location.href = process.env.BASE_API + '/product/export';
  246. },
  247. changeState(id, status) {
  248. setState({ id: id, status: status }).then(response => {
  249. this.$notify({
  250. title: '成功',
  251. message: '状态修改成功',
  252. type: 'success',
  253. duration: 2000
  254. })
  255. this.getList()
  256. })
  257. },
  258. }
  259. }
  260. </script>