index.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!-- 供应商管理 -->
  2. <template>
  3. <div class="supplier-management">
  4. <!-- 顶部操作区 -->
  5. <div class="top-actions">
  6. <a-space>
  7. <a-button type="primary" @click="showNewSupplierForm">{{ $t('supplier.addSupplier') }}</a-button>
  8. </a-space>
  9. </div>
  10. <!-- 搜索条件区 -->
  11. <div class="search-section">
  12. <a-form :model="searchForm" layout="inline">
  13. <a-form-item field="supplierName" :label="$t('supplier.supplierName')">
  14. <a-input v-model="searchForm.supplierName" :placeholder="$t('supplier.enterSupplierName')"
  15. allow-clear />
  16. </a-form-item>
  17. <a-form-item field="operatorType" :label="$t('supplier.operatorType')">
  18. <a-select v-model="searchForm.operatorType" :placeholder="$t('supplier.selectOperatorType')"
  19. allow-clear style="width: 160px">
  20. <a-option v-for="op in operatorTypeOptions" :key="op.value" :value="op.value">
  21. {{ $t(`supplier.operatorTypes.${op.value}`) }}
  22. </a-option>
  23. </a-select>
  24. </a-form-item>
  25. <a-form-item>
  26. <a-button type="primary" @click="handleSearch">{{ $t('global.common.search') }}</a-button>
  27. </a-form-item>
  28. <a-form-item>
  29. <a-button @click="resetSearch">{{ $t('global.common.reset') }}</a-button>
  30. </a-form-item>
  31. </a-form>
  32. </div>
  33. <!-- 数据表格 -->
  34. <a-table :columns="columns" :data="tableData" :pagination="pagination" :scroll="{ x: '100%', y: '400px' }">
  35. <template #operation="{ record }">
  36. <a-space>
  37. <a-button type="text" size="small" @click="handleEdit(record)">{{ $t('global.common.edit')
  38. }}</a-button>
  39. <a-button type="text" size="small" @click="handleDelete(record)">{{ $t('global.common.delete')
  40. }}</a-button>
  41. </a-space>
  42. </template>
  43. </a-table>
  44. <!-- 新供应商表单对话框 -->
  45. <new-supplier-form v-model:visible="newSupplierFormVisible" :editMode="editMode" :editData="editData"
  46. @submit="handleNewSupplierSubmit" />
  47. </div>
  48. </template>
  49. <script setup>
  50. import { ref, reactive, computed } from 'vue';
  51. import { Message } from '@arco-design/web-vue';
  52. import { useI18n } from 'vue-i18n';
  53. import NewSupplierForm from './NewSupplierForm.vue';
  54. const { t } = useI18n();
  55. const columns = computed(() => [
  56. { title: t('supplier.id'), dataIndex: 'id' },
  57. { title: t('supplier.operatorCode'), dataIndex: 'operatorCode' },
  58. { title: t('supplier.operatorName'), dataIndex: 'operatorName' },
  59. { title: t('supplier.operatorType'), dataIndex: 'operatorType' },
  60. { title: t('supplier.updateTime'), dataIndex: 'updateTime' },
  61. { title: t('global.common.operations'), slotName: 'operation', width: 150 },
  62. ]);
  63. const tableData = reactive([]);
  64. const pagination = reactive({
  65. total: 0,
  66. current: 1,
  67. pageSize: 10,
  68. });
  69. const newSupplierFormVisible = ref(false);
  70. const editMode = ref(false);
  71. const editData = ref(null);
  72. const showNewSupplierForm = () => {
  73. editMode.value = false;
  74. editData.value = null;
  75. newSupplierFormVisible.value = true;
  76. };
  77. const handleEdit = (record) => {
  78. editMode.value = true;
  79. editData.value = { ...record };
  80. newSupplierFormVisible.value = true;
  81. };
  82. const handleDelete = (record) => {
  83. Message.success(`已删除供应商 ${record.operatorName}`);
  84. const index = tableData.findIndex(item => item.id === record.id);
  85. if (index !== -1) {
  86. tableData.splice(index, 1);
  87. }
  88. };
  89. const handleNewSupplierSubmit = (formData) => {
  90. if (editMode.value) {
  91. console.log('Edited supplier submitted:', formData);
  92. Message.success(`已更新供应商 ${formData.operatorName}`);
  93. } else {
  94. console.log('New supplier submitted:', formData);
  95. Message.success(`已添加新供应商 ${formData.operatorName}`);
  96. }
  97. };
  98. const searchForm = reactive({
  99. supplierName: '',
  100. operatorType: '',
  101. });
  102. const operatorTypeOptions = [
  103. { label: t('supplier.operatorTypes.foreign_local'), value: 'foreign_local' },
  104. { label: t('supplier.operatorTypes.international'), value: 'international' },
  105. ];
  106. const handleSearch = () => {
  107. console.log('Search form data:', searchForm);
  108. Message.success(t('supplier.searchExecuted'));
  109. };
  110. const resetSearch = () => {
  111. Object.keys(searchForm).forEach(key => {
  112. searchForm[key] = '';
  113. });
  114. Message.success(t('supplier.searchReset'));
  115. };
  116. </script>
  117. <style scoped>
  118. .supplier-management {
  119. padding: 20px !important;
  120. }
  121. .top-actions {
  122. margin-bottom: 20px;
  123. }
  124. .search-section {
  125. margin-bottom: 20px;
  126. }
  127. .supplier-management .arco-table-th {
  128. white-space: nowrap;
  129. }
  130. </style>