zhuo
2025-02-15 914ba8443320e9b4b46a641a82799c8bfdc63056
src/views/system/customer/index.vue
@@ -59,7 +59,7 @@
<script>
import limsTable from '@/components/Table/lims-table.vue'
import {addCustom, selectCustomPageList, upCustom} from "@/api/system/customer";
import {addCustom, delCustomById, selectCustomPageList, upCustom} from "@/api/system/customer";
export default {
  components: {
    limsTable
@@ -90,6 +90,12 @@
              clickFun: (row) => {
                this.openFormDia('edit', row);
              },
            },{
              name: '删除',
              type: 'text',
              clickFun: (row) => {
                this.delete(row);
              },
            },
          ]
        }
@@ -105,9 +111,7 @@
      formTitle: '',
      addDia: false,
      addPower: true,
      user: {
        name: null
      },
      user: {},
      userRules: {
        company: [{ required: true, message: '请输入客户名称', trigger: 'blur' }],
        companyEn: [{ required: true, message: '请输入客户名称EN', trigger: 'blur' }],
@@ -130,8 +134,8 @@
      selectCustomPageList({...this.queryParams, ...this.page}).then(res => {
        this.tableLoading = false
        if (res.code === 200) {
          this.tableData = res.data
          this.page.total = res.total
          this.tableData = res.data.records
          this.page.total = res.data.total
        }
      }).catch(err => {
        this.tableLoading = false
@@ -146,6 +150,9 @@
      this.addDia = true
      this.formTitle = type === 'add' ? '新增客户' : '编辑客户'
      this.operationType = type
      if (type === 'edit') {
        this.user = row
      }
    },
    customAdd() {
      this.$refs['userForm'].validate((valid) => {
@@ -153,19 +160,23 @@
          this.loading = true
          if (this.operationType === 'add') {
            addCustom(this.user).then(res => {
              if (res.code === 201) return
              this.loading = false
              if (res.code !== 200) return
              this.$message.success('新增成功')
              this.getList()
              this.loading = false
              this.reset()
            }).catch(err => {
              this.loading = false
            })
          } else {
            upCustom(this.user).then(res => {
              if (res.code === 201) return
              this.loading = false
              if (res.code !== 200) return
              this.$message.success('修改成功')
              this.getList()
              this.loading = false
              this.reset()
            }).catch(err => {
              this.loading = false
            })
          }
        }
@@ -174,6 +185,23 @@
    reset () {
      this.addDia = false
      this.resetForm("userForm");
    },
    delete (row) {
      this.$confirm('是否删除当前数据?', "警告", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        delCustomById({id: row.id}).then(res => {
          if (res.code === 500) {
            return
          }
          this.$message.success('删除成功')
          this.getList()
        }).catch(e => {
          this.$message.error('删除失败')
        })
      }).catch(() => {})
    }
  }
}