index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <el-container class="is-vertical">
  3. <sc-page-header @add="table_add"></sc-page-header>
  4. <scTable ref="xGridTable" :apiObj="$API.easyRun.supplier" :formConfig="formConfig" :paramsColums="paramsColums" :toolbarConfig="toolbarConfig" :columns="columns">
  5. <template #action="{ row }">
  6. <el-button type="primary" link @click="table_edit(row)">
  7. <template #icon><sc-iconify icon="ant-design:edit-outlined"></sc-iconify></template>修改
  8. </el-button>
  9. <el-button type="primary" link @click="table_del(row)">
  10. <template #icon><sc-iconify icon="ant-design:delete-outlined"></sc-iconify></template>删除
  11. </el-button>
  12. </template>
  13. </scTable>
  14. </el-container>
  15. <supplier-detail v-if="dialog" ref="supplierRef" @success="refreshTable" @closed="dialog = false"></supplier-detail>
  16. </template>
  17. <script setup>
  18. import XEUtils from "xe-utils";
  19. import API from "@/api";
  20. import { mapFormItemInput } from "@/components/scTable/helper";
  21. import supplierDetail from "./detail";
  22. const companyTypeDic = reactive({
  23. firm: "厂商",
  24. provider: "服务商"
  25. });
  26. const toolbarConfig = reactive({
  27. enabled: true,
  28. import: true,
  29. export: true
  30. });
  31. const formConfig = reactive({
  32. data: {},
  33. items: [
  34. mapFormItemInput("companyName", "供应商名称")
  35. ]
  36. });
  37. const paramsColums = reactive([
  38. { type: "relation", column: "companyName", symbol: "like" }
  39. ])
  40. const columns = reactive([
  41. { type: "seq", width: 60 },
  42. { type: "html", field: "companyName", title: "供应商名称", minWidth: 150, sortable: true },
  43. { type: "html", field: "type", title: "类型", minWidth: 100, sortable: true, formatter: ({ cellValue }) => XEUtils.get(companyTypeDic, cellValue, cellValue) },
  44. { type: "html", field: "creditNo", title: "统一社会信用代码", minWidth: 150, sortable: true },
  45. { type: "html", field: "contactsName", title: "联系人", minWidth: 120, sortable: true },
  46. { type: "html", field: "contactsPhone", title: "联系方式", minWidth: 120, sortable: true },
  47. { title: "操作", width: 140, slots: { default: "action" } }
  48. ])
  49. // 显示隐藏 筛选表单
  50. const xGridTable = ref();
  51. const refreshTable = (mode = "add") => {
  52. xGridTable.value.reloadColumn(columns);
  53. xGridTable.value.searchData(mode);
  54. }
  55. const supplierRef = ref();
  56. const dialog = ref(false);
  57. const table_add = () => {
  58. dialog.value = true;
  59. nextTick(() => supplierRef.value?.open());
  60. }
  61. const table_edit = row => {
  62. dialog.value = true;
  63. nextTick(() => supplierRef.value?.setData(row));
  64. }
  65. const table_del = row => {
  66. ElMessageBox.confirm("是否确认删除该供应商?", "删除警告", {
  67. type: "warning",
  68. confirmButtonText: "确定",
  69. cancelButtonText: "取消"
  70. }).then(() => {
  71. API.easyRun.supplier.del(row.id).then(() => {
  72. ElMessage.success("操作成功");
  73. refreshTable();
  74. });
  75. });
  76. }
  77. </script>