VUE框架通过封装的Axios获取并提交数据实现工单管理前端页面效果------VUE框架

<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-switch v-model="show" active-text="显示已处理" inactive-text="不显示已处理">
        </el-switch>
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column type="selection" header-align="center" align="center" width="50">
      </el-table-column>
      <el-table-column prop="id" header-align="center" align="center" label="工单编号(主键)">
      </el-table-column>
      <el-table-column prop="customerName" header-align="center" align="center" label="客户姓名">
      </el-table-column>
      <el-table-column prop="contactPhone" header-align="center" align="center" label="联系电话">
      </el-table-column>
      <el-table-column prop="title" header-align="center" align="center" label="工单标题">
      </el-table-column>
      <el-table-column prop="description" header-align="center" align="center" label="问题描述">
      </el-table-column>
      <el-table-column prop="status" header-align="center" align="center" label="处理状态">
      </el-table-column>
      <el-table-column prop="suggestion" header-align="center" align="center" label="处理建议">
      </el-table-column>
      <el-table-column prop="handler" header-align="center" align="center" label="处理人">
      </el-table-column>
      <el-table-column prop="submitTime" header-align="center" align="center" label="工单提交时间">
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" v-if="scope.row.status != 0"
            @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <el-button type="text" size="small" v-if="scope.row.status != 1"
            @click="handleHandle(scope.row.id)">处理</el-button>
          <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <Handler v-if="handleVisible" ref="handler" @refreshDataList="getDataList"></Handler>
  </div>
</template>

<script>
import AddOrUpdate from './tickets-add-or-update.vue'
import Handler from './tickets-handler.vue'
export default {
  data() {
    return {
      show : true,
      handleVisible: false,
      dataForm: {
        key: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false
    }
  },
  components: {
    AddOrUpdate,
    Handler
  },
  activated() {
    this.getDataList()
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/mall/tickets/list'),
        method: 'get',
        params: this.$http.adornParams({
          'page': this.pageIndex,
          'limit': this.pageSize,
          'key': this.dataForm.key
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
      })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id)
      })
    },
    handleHandle(id) {
      this.handleVisible = true
      this.$nextTick(() => {
        this.$refs.handler.init(id)
      })
    },
    // 删除
    deleteHandle(id) {
      var ids = id ? [id] : this.dataListSelections.map(item => {
        return item.id
      })
      this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl('/mall/tickets/delete'),
          method: 'post',
          data: this.$http.adornData(ids, false)
        }).then(({ data }) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList()
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      })
    }
  }
}
</script>

<template>
  <div class="mod-config">
    <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
      <el-form-item>
        <el-input v-model="dataForm.key" placeholder="参数名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button @click="getDataList()">查询</el-button>
        <el-switch v-model="show" active-text="显示已处理" inactive-text="不显示已处理">
        </el-switch>
        <el-button type="primary" @click="addOrUpdateHandle()">新增</el-button>
        <el-button type="danger" @click="deleteHandle()" :disabled="dataListSelections.length <= 0">批量删除</el-button>
      </el-form-item>
    </el-form>
    <el-table :data="dataList" border v-loading="dataListLoading" @selection-change="selectionChangeHandle"
      style="width: 100%;">
      <el-table-column type="selection" header-align="center" align="center" width="50">
      </el-table-column>
      <el-table-column prop="id" header-align="center" align="center" label="工单编号(主键)">
      </el-table-column>
      <el-table-column prop="customerName" header-align="center" align="center" label="客户姓名">
      </el-table-column>
      <el-table-column prop="contactPhone" header-align="center" align="center" label="联系电话">
      </el-table-column>
      <el-table-column prop="title" header-align="center" align="center" label="工单标题">
      </el-table-column>
      <el-table-column prop="description" header-align="center" align="center" label="问题描述">
      </el-table-column>
      <el-table-column prop="status" header-align="center" align="center" label="处理状态">
      </el-table-column>
      <el-table-column prop="suggestion" header-align="center" align="center" label="处理建议">
      </el-table-column>
      <el-table-column prop="handler" header-align="center" align="center" label="处理人">
      </el-table-column>
      <el-table-column prop="submitTime" header-align="center" align="center" label="工单提交时间">
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" v-if="scope.row.status != 0"
            @click="addOrUpdateHandle(scope.row.id)">修改</el-button>
          <el-button type="text" size="small" v-if="scope.row.status != 1"
            @click="handleHandle(scope.row.id)">处理</el-button>
          <el-button type="text" size="small" @click="deleteHandle(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage"
      layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
    <!-- 弹窗, 新增 / 修改 -->
    <add-or-update v-if="addOrUpdateVisible" ref="addOrUpdate" @refreshDataList="getDataList"></add-or-update>
    <Handler v-if="handleVisible" ref="handler" @refreshDataList="getDataList"></Handler>
  </div>
</template>

<script>
import AddOrUpdate from './tickets-add-or-update.vue'
import Handler from './tickets-handler.vue'
export default {
  data() {
    return {
      show : true,
      handleVisible: false,
      dataForm: {
        key: ''
      },
      dataList: [],
      pageIndex: 1,
      pageSize: 10,
      totalPage: 0,
      dataListLoading: false,
      dataListSelections: [],
      addOrUpdateVisible: false
    }
  },
  components: {
    AddOrUpdate,
    Handler
  },
  activated() {
    this.getDataList()
  },
  methods: {
    // 获取数据列表
    getDataList() {
      this.dataListLoading = true
      this.$http({
        url: this.$http.adornUrl('/mall/tickets/list'),
        method: 'get',
        params: this.$http.adornParams({
          'page': this.pageIndex,
          'limit': this.pageSize,
          'key': this.dataForm.key
        })
      }).then(({ data }) => {
        if (data && data.code === 0) {
          this.dataList = data.page.list
          this.totalPage = data.page.totalCount
        } else {
          this.dataList = []
          this.totalPage = 0
        }
        this.dataListLoading = false
      })
    },
    // 每页数
    sizeChangeHandle(val) {
      this.pageSize = val
      this.pageIndex = 1
      this.getDataList()
    },
    // 当前页
    currentChangeHandle(val) {
      this.pageIndex = val
      this.getDataList()
    },
    // 多选
    selectionChangeHandle(val) {
      this.dataListSelections = val
    },
    // 新增 / 修改
    addOrUpdateHandle(id) {
      this.addOrUpdateVisible = true
      this.$nextTick(() => {
        this.$refs.addOrUpdate.init(id)
      })
    },
    handleHandle(id) {
      this.handleVisible = true
      this.$nextTick(() => {
        this.$refs.handler.init(id)
      })
    },
    // 删除
    deleteHandle(id) {
      var ids = id ? [id] : this.dataListSelections.map(item => {
        return item.id
      })
      this.$confirm(`确定对[id=${ids.join(',')}]进行[${id ? '删除' : '批量删除'}]操作?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.$http({
          url: this.$http.adornUrl('/mall/tickets/delete'),
          method: 'post',
          data: this.$http.adornData(ids, false)
        }).then(({ data }) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1500,
              onClose: () => {
                this.getDataList()
              }
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      })
    }
  }
}
</script>
 

<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="客户姓名" prop="customerName">
      <el-input v-model="dataForm.customerName" placeholder="客户姓名"></el-input>
    </el-form-item>
    <el-form-item label="联系电话" prop="contactPhone">
      <el-input v-model="dataForm.contactPhone" placeholder="联系电话"></el-input>
    </el-form-item>
    <el-form-item label="工单标题" prop="title">
      <el-input v-model="dataForm.title" placeholder="工单标题"></el-input>
    </el-form-item>
    <el-form-item label="问题描述" prop="description">
      <el-input v-model="dataForm.description" placeholder="问题描述"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          customerName: '',
          contactPhone: '',
          title: '',
          description: '',
        },
        dataRule: {
          customerName: [
            { required: true, message: '客户姓名不能为空', trigger: 'blur' }
          ],
          contactPhone: [
            { required: true, message: '联系电话不能为空', trigger: 'blur' }
          ],
          title: [
            { required: true, message: '工单标题不能为空', trigger: 'blur' }
          ],
          description: [
            { required: true, message: '问题描述不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/mall/tickets/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.customerName = data.tickets.customerName
                this.dataForm.contactPhone = data.tickets.contactPhone
                this.dataForm.title = data.tickets.title
                this.dataForm.description = data.tickets.description
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/mall/tickets/${!this.dataForm.id ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'id': this.dataForm.id || undefined,
                'customerName': this.dataForm.customerName,
                'contactPhone': this.dataForm.contactPhone,
                'title': this.dataForm.title,
                'description': this.dataForm.description,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>

<template>
  <el-dialog
    :title="!dataForm.id ? '新增' : '修改'"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="80px">
    <el-form-item label="客户姓名" prop="customerName">
      <el-input v-model="dataForm.customerName" placeholder="客户姓名"></el-input>
    </el-form-item>
    <el-form-item label="联系电话" prop="contactPhone">
      <el-input v-model="dataForm.contactPhone" placeholder="联系电话"></el-input>
    </el-form-item>
    <el-form-item label="工单标题" prop="title">
      <el-input v-model="dataForm.title" placeholder="工单标题"></el-input>
    </el-form-item>
    <el-form-item label="问题描述" prop="description">
      <el-input v-model="dataForm.description" placeholder="问题描述"></el-input>
    </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          id: 0,
          customerName: '',
          contactPhone: '',
          title: '',
          description: '',
        },
        dataRule: {
          customerName: [
            { required: true, message: '客户姓名不能为空', trigger: 'blur' }
          ],
          contactPhone: [
            { required: true, message: '联系电话不能为空', trigger: 'blur' }
          ],
          title: [
            { required: true, message: '工单标题不能为空', trigger: 'blur' }
          ],
          description: [
            { required: true, message: '问题描述不能为空', trigger: 'blur' }
          ]
        }
      }
    },
    methods: {
      init (id) {
        this.dataForm.id = id || 0
        this.visible = true
        this.$nextTick(() => {
          this.$refs['dataForm'].resetFields()
          if (this.dataForm.id) {
            this.$http({
              url: this.$http.adornUrl(`/mall/tickets/info/${this.dataForm.id}`),
              method: 'get',
              params: this.$http.adornParams()
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.dataForm.customerName = data.tickets.customerName
                this.dataForm.contactPhone = data.tickets.contactPhone
                this.dataForm.title = data.tickets.title
                this.dataForm.description = data.tickets.description
              }
            })
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$refs['dataForm'].validate((valid) => {
          if (valid) {
            this.$http({
              url: this.$http.adornUrl(`/mall/tickets/${!this.dataForm.id ? 'save' : 'update'}`),
              method: 'post',
              data: this.$http.adornData({
                'id': this.dataForm.id || undefined,
                'customerName': this.dataForm.customerName,
                'contactPhone': this.dataForm.contactPhone,
                'title': this.dataForm.title,
                'description': this.dataForm.description,
              })
            }).then(({data}) => {
              if (data && data.code === 0) {
                this.$message({
                  message: '操作成功',
                  type: 'success',
                  duration: 1500,
                  onClose: () => {
                    this.visible = false
                    this.$emit('refreshDataList')
                  }
                })
              } else {
                this.$message.error(data.msg)
              }
            })
          }
        })
      }
    }
  }
</script>
 

<template>
  <el-dialog title="工单处理" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
      label-width="80px">
      <el-form-item label="处理人" prop="customerName">
        <el-input v-model="dataForm.handler" :value="handler"></el-input>
      </el-form-item>
      <el-form-item label="建议" prop="contactPhone">
        <el-input v-model="dataForm.suggestion" placeholder="建议"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        handler: '',
        suggestion: '',
      },
      dataRule: {
        handler: [
          { required: true, message: '处理人不能为空', trigger: 'blur' }
        ],
        suggestion: [
          { required: true, message: '建议不能为空', trigger: 'blur' }
        ],
      }
    }
  },
  computed: {
    handler: {
      get() { return this.$store.state.user.name },
    }
  },
  created() {
    // 手动触发一次计算属性的 getter 方法
    this.dataForm.handler = this.handler;
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if (this.dataForm.id) {
          this.$http({
            url: this.$http.adornUrl(`/mall/tickets/info/${this.dataForm.id}`),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.dataForm.customerName = data.tickets.customerName
              this.dataForm.contactPhone = data.tickets.contactPhone
              this.dataForm.title = data.tickets.title
              this.dataForm.description = data.tickets.description
            }
          })
        }
      })
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl("/mall/tickets/update"),
            method: 'put',
            data: this.$http.adornData({
              'id': this.dataForm.id || undefined,
              'handler': this.dataForm.handler,
              'suggestion': this.dataForm.suggestion,
            })
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.visible = false
                  this.$emit('refreshDataList')
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        }
      })
    }
  }
}
</script>

<template>
  <el-dialog title="工单处理" :close-on-click-modal="false" :visible.sync="visible">
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()"
      label-width="80px">
      <el-form-item label="处理人" prop="customerName">
        <el-input v-model="dataForm.handler" :value="handler"></el-input>
      </el-form-item>
      <el-form-item label="建议" prop="contactPhone">
        <el-input v-model="dataForm.suggestion" placeholder="建议"></el-input>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      visible: false,
      dataForm: {
        id: 0,
        handler: '',
        suggestion: '',
      },
      dataRule: {
        handler: [
          { required: true, message: '处理人不能为空', trigger: 'blur' }
        ],
        suggestion: [
          { required: true, message: '建议不能为空', trigger: 'blur' }
        ],
      }
    }
  },
  computed: {
    handler: {
      get() { return this.$store.state.user.name },
    }
  },
  created() {
    // 手动触发一次计算属性的 getter 方法
    this.dataForm.handler = this.handler;
  },
  methods: {
    init(id) {
      this.dataForm.id = id || 0
      this.visible = true
      this.$nextTick(() => {
        this.$refs['dataForm'].resetFields()
        if (this.dataForm.id) {
          this.$http({
            url: this.$http.adornUrl(`/mall/tickets/info/${this.dataForm.id}`),
            method: 'get',
            params: this.$http.adornParams()
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.dataForm.customerName = data.tickets.customerName
              this.dataForm.contactPhone = data.tickets.contactPhone
              this.dataForm.title = data.tickets.title
              this.dataForm.description = data.tickets.description
            }
          })
        }
      })
    },
    // 表单提交
    dataFormSubmit() {
      this.$refs['dataForm'].validate((valid) => {
        if (valid) {
          this.$http({
            url: this.$http.adornUrl("/mall/tickets/update"),
            method: 'put',
            data: this.$http.adornData({
              'id': this.dataForm.id || undefined,
              'handler': this.dataForm.handler,
              'suggestion': this.dataForm.suggestion,
            })
          }).then(({ data }) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.visible = false
                  this.$emit('refreshDataList')
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        }
      })
    }
  }
}
</script>

  • 9
    点赞
  • 19
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值