基础资料已完善
							parent
							
								
									d7e2542a00
								
							
						
					
					
						commit
						1131f19726
					
				| 
						 | 
				
			
			@ -0,0 +1,69 @@
 | 
			
		|||
/**
 | 
			
		||||
 * 收货地址 api 封装
 | 
			
		||||
 *
 | 
			
		||||
 * @Author:    hj
 | 
			
		||||
 * @Date:      2024-12-26 15:35:23
 | 
			
		||||
 * @Copyright  友仓
 | 
			
		||||
 */
 | 
			
		||||
import {postRequest, getRequest,getDownload} from '/@/lib/axios';
 | 
			
		||||
 | 
			
		||||
export const addressApi = {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 分页查询  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    queryPage: (param) => {
 | 
			
		||||
        return postRequest('/address/queryPage', param);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 增加  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    add: (param) => {
 | 
			
		||||
        return postRequest('/address/add', param);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 修改  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    update: (param) => {
 | 
			
		||||
        return postRequest('/address/update', param);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 删除  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    delete: (addressId: number) => {
 | 
			
		||||
        return getRequest('/address/delete', {addressId});
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 批量删除  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    batchDelete: (idList: number[]) => {
 | 
			
		||||
        return postRequest('/address/batchDelete', idList);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 下拉查询  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    queryAddress: (param: object) => {
 | 
			
		||||
        return postRequest('/address/queryAddress', param);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 导入  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    importAddress: (file: object) => {
 | 
			
		||||
        return postRequest('/address/importAddress', file);
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 导出  @author  hj
 | 
			
		||||
     */
 | 
			
		||||
    exportAddress: () => {
 | 
			
		||||
        return getDownload('/address/exportAddress',{});
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,11 @@
 | 
			
		|||
/**
 | 
			
		||||
 * 收货地址 枚举
 | 
			
		||||
 *
 | 
			
		||||
 * @Author:    hj
 | 
			
		||||
 * @Date:      2024-12-26 15:35:23
 | 
			
		||||
 * @Copyright  友仓
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export default {
 | 
			
		||||
};
 | 
			
		||||
| 
						 | 
				
			
			@ -39,6 +39,7 @@ export const TABLE_ID_CONST = {
 | 
			
		|||
      LOCATION:businessBASEInitTableId+2,//库位
 | 
			
		||||
      ITEM:businessBASEInitTableId+3,//商品
 | 
			
		||||
      STOCK:businessBASEInitTableId+4,//容器
 | 
			
		||||
      ADDRESS:businessBASEInitTableId+5,//地址
 | 
			
		||||
    }
 | 
			
		||||
  },
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,128 @@
 | 
			
		|||
<!--
 | 
			
		||||
  * 收货地址
 | 
			
		||||
  *
 | 
			
		||||
  * @Author:    hj
 | 
			
		||||
  * @Date:      2024-12-26 15:35:23
 | 
			
		||||
  * @Copyright  友仓
 | 
			
		||||
-->
 | 
			
		||||
<template>
 | 
			
		||||
  <a-modal
 | 
			
		||||
      :title="form.addressId ? '编辑地址' : '添加地址'"
 | 
			
		||||
      :width="600"
 | 
			
		||||
      :open="visibleFlag"
 | 
			
		||||
      @cancel="onClose"
 | 
			
		||||
      :maskClosable="false"
 | 
			
		||||
      :destroyOnClose="true"
 | 
			
		||||
  >
 | 
			
		||||
    <a-form ref="formRef" :model="form" :rules="rules" :label-col="{ span: 5 }" >
 | 
			
		||||
 | 
			
		||||
        <a-form-item label="收货单位"  name="name">
 | 
			
		||||
          <a-input style="width: 100%" v-model:value="form.name" placeholder="收货单位" />
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item label="联系人"  name="person">
 | 
			
		||||
          <a-input style="width: 100%" v-model:value="form.person" placeholder="联系人" />
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
        <a-form-item label="电话"  name="telephone">
 | 
			
		||||
          <a-input style="width: 100%" v-model:value="form.telephone" placeholder="电话" />
 | 
			
		||||
        </a-form-item>
 | 
			
		||||
      <a-form-item label="地址" name="address">
 | 
			
		||||
        <textarea v-model="form.address" style="width: 100%; height: 100px; outline: none"></textarea>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
    </a-form>
 | 
			
		||||
 | 
			
		||||
    <template #footer>
 | 
			
		||||
      <a-space>
 | 
			
		||||
        <a-button @click="onClose">取消</a-button>
 | 
			
		||||
        <a-button type="primary" @click="onSubmit">保存</a-button>
 | 
			
		||||
      </a-space>
 | 
			
		||||
    </template>
 | 
			
		||||
  </a-modal>
 | 
			
		||||
</template>
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
  import { reactive, ref, nextTick } from 'vue';
 | 
			
		||||
  import _ from 'lodash';
 | 
			
		||||
  import { message } from 'ant-design-vue';
 | 
			
		||||
  import { SmartLoading } from '/@/components/framework/smart-loading';
 | 
			
		||||
  import { addressApi } from '/@/api/business/base/address/address-api';
 | 
			
		||||
  import { smartSentry } from '/@/lib/smart-sentry';
 | 
			
		||||
 | 
			
		||||
  // ------------------------ 事件 ------------------------
 | 
			
		||||
 | 
			
		||||
  const emits = defineEmits(['reloadList']);
 | 
			
		||||
 | 
			
		||||
  // ------------------------ 显示与隐藏 ------------------------
 | 
			
		||||
  // 是否显示
 | 
			
		||||
  const visibleFlag = ref(false);
 | 
			
		||||
 | 
			
		||||
  function show(rowData) {
 | 
			
		||||
    Object.assign(form, formDefault);
 | 
			
		||||
    if (rowData && !_.isEmpty(rowData)) {
 | 
			
		||||
      Object.assign(form, rowData);
 | 
			
		||||
    }
 | 
			
		||||
    // 使用字典时把下面这注释修改成自己的字典字段 有多个字典字段就复制多份同理修改 不然打开表单时不显示字典初始值
 | 
			
		||||
    // if (form.status && form.status.length > 0) {
 | 
			
		||||
    //   form.status = form.status.map((e) => e.valueCode);
 | 
			
		||||
    // }
 | 
			
		||||
    visibleFlag.value = true;
 | 
			
		||||
    nextTick(() => {
 | 
			
		||||
      formRef.value.clearValidate();
 | 
			
		||||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  function onClose() {
 | 
			
		||||
    Object.assign(form, formDefault);
 | 
			
		||||
    visibleFlag.value = false;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // ------------------------ 表单 ------------------------
 | 
			
		||||
 | 
			
		||||
  // 组件ref
 | 
			
		||||
  const formRef = ref();
 | 
			
		||||
 | 
			
		||||
  const formDefault = {
 | 
			
		||||
      addressId: undefined, //收货地址id
 | 
			
		||||
      name: undefined, //名称/单位
 | 
			
		||||
      person: undefined, //联系人
 | 
			
		||||
      telephone: undefined, //电话
 | 
			
		||||
      address: undefined, //地址
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  let form = reactive({ ...formDefault });
 | 
			
		||||
 | 
			
		||||
  const rules = {
 | 
			
		||||
      addressId: [{ required: true, message: '收货地址id 必填' }],
 | 
			
		||||
  };
 | 
			
		||||
 | 
			
		||||
  // 点击确定,验证表单
 | 
			
		||||
  async function onSubmit() {
 | 
			
		||||
    try {
 | 
			
		||||
      await formRef.value.validateFields();
 | 
			
		||||
      await save();
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      message.error('参数验证错误,请仔细填写表单数据!');
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  // 新建、编辑API
 | 
			
		||||
  async function save() {
 | 
			
		||||
    SmartLoading.show();
 | 
			
		||||
    try {
 | 
			
		||||
      if (form.addressId) {
 | 
			
		||||
        await addressApi.update(form);
 | 
			
		||||
      } else {
 | 
			
		||||
        await addressApi.add(form);
 | 
			
		||||
      }
 | 
			
		||||
      message.success('操作成功');
 | 
			
		||||
      emits('reloadList');
 | 
			
		||||
      onClose();
 | 
			
		||||
    } catch (err) {
 | 
			
		||||
      smartSentry.captureError(err);
 | 
			
		||||
    } finally {
 | 
			
		||||
      SmartLoading.hide();
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  defineExpose({
 | 
			
		||||
    show,
 | 
			
		||||
  });
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,422 @@
 | 
			
		|||
<!--
 | 
			
		||||
  * 收货地址
 | 
			
		||||
  *
 | 
			
		||||
  * @Author:    hj
 | 
			
		||||
  * @Date:      2024-12-26 15:35:23
 | 
			
		||||
  * @Copyright  友仓
 | 
			
		||||
-->
 | 
			
		||||
<template>
 | 
			
		||||
  <!---------- 查询表单form begin ----------->
 | 
			
		||||
  <a-form class="smart-query-form">
 | 
			
		||||
    <a-row class="smart-query-form-row">
 | 
			
		||||
      <a-form-item label="收货单位" class="smart-query-form-item">
 | 
			
		||||
        <AddressSelect v-model:value="queryForm.addressId" @change="changeAddressSelect"/>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
      <a-form-item class="smart-query-form-item">
 | 
			
		||||
        <a-button type="primary" @click="onSearch" class="smart-margin-left10">
 | 
			
		||||
          <template #icon>
 | 
			
		||||
            <SearchOutlined/>
 | 
			
		||||
          </template>
 | 
			
		||||
          查询
 | 
			
		||||
        </a-button>
 | 
			
		||||
        <a-button @click="resetQuery" class="smart-margin-left10">
 | 
			
		||||
          <template #icon>
 | 
			
		||||
            <ReloadOutlined/>
 | 
			
		||||
          </template>
 | 
			
		||||
          重置
 | 
			
		||||
        </a-button>
 | 
			
		||||
      </a-form-item>
 | 
			
		||||
    </a-row>
 | 
			
		||||
  </a-form>
 | 
			
		||||
  <!---------- 查询表单form end ----------->
 | 
			
		||||
 | 
			
		||||
  <a-card size="small" :bordered="false" :hoverable="true">
 | 
			
		||||
    <!---------- 表格操作行 begin ----------->
 | 
			
		||||
    <a-row class="smart-table-btn-block">
 | 
			
		||||
      <div class="smart-table-operate-block">
 | 
			
		||||
        <a-button @click="showForm" type="primary" v-privilege="'address:add'">
 | 
			
		||||
          <template #icon>
 | 
			
		||||
            <PlusOutlined/>
 | 
			
		||||
          </template>
 | 
			
		||||
          新建
 | 
			
		||||
        </a-button>
 | 
			
		||||
        <a-button @click="confirmBatchDelete" type="primary" danger v-privilege="'address:batchDelete'"
 | 
			
		||||
                  :disabled="selectedRowKeyList.length == 0">
 | 
			
		||||
          <template #icon>
 | 
			
		||||
            <DeleteOutlined/>
 | 
			
		||||
          </template>
 | 
			
		||||
          批量删除
 | 
			
		||||
        </a-button>
 | 
			
		||||
 | 
			
		||||
        <a-button @click="showImportModal" type="primary" v-privilege="'address:importAddress'">
 | 
			
		||||
          <template #icon>
 | 
			
		||||
            <ImportOutlined/>
 | 
			
		||||
          </template>
 | 
			
		||||
          导入
 | 
			
		||||
        </a-button>
 | 
			
		||||
 | 
			
		||||
        <a-button @click="onExportAddress" type="primary" v-privilege="'address:exportAddress'">
 | 
			
		||||
          <template #icon>
 | 
			
		||||
            <ExportOutlined/>
 | 
			
		||||
          </template>
 | 
			
		||||
          导出
 | 
			
		||||
        </a-button>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="smart-table-setting-block">
 | 
			
		||||
        <TableOperator v-model="columns" :tableId="TABLE_ID_CONST.BUSINESS.BASE.ADDRESS" :refresh="queryData"/>
 | 
			
		||||
      </div>
 | 
			
		||||
    </a-row>
 | 
			
		||||
    <!---------- 表格操作行 end ----------->
 | 
			
		||||
 | 
			
		||||
    <!---------- 表格 begin ----------->
 | 
			
		||||
    <a-table
 | 
			
		||||
        size="small"
 | 
			
		||||
        :dataSource="tableData"
 | 
			
		||||
        :columns="columns"
 | 
			
		||||
        rowKey="addressId"
 | 
			
		||||
        bordered
 | 
			
		||||
        :loading="tableLoading"
 | 
			
		||||
        :pagination="false"
 | 
			
		||||
        :row-selection="{ selectedRowKeys: selectedRowKeyList, onChange: onSelectChange }"
 | 
			
		||||
    >
 | 
			
		||||
      <template #bodyCell="{ text, record, column }">
 | 
			
		||||
 | 
			
		||||
        <!-- 有图片预览时 注释解开并把下面的'picture'修改成自己的图片字段名即可 -->
 | 
			
		||||
        <!-- <template v-if="column.dataIndex === 'picture'">
 | 
			
		||||
            <FilePreview :fileList="text" type="picture" />
 | 
			
		||||
          </template> -->
 | 
			
		||||
 | 
			
		||||
        <!-- 使用字典时 注释解开并把下面的'dict'修改成自己的字典字段名即可 有多个字典字段就复制多份同理修改 不然不显示字典 -->
 | 
			
		||||
        <!-- 方便修改tag的颜色 orange green purple success processing error default warning -->
 | 
			
		||||
        <!-- <template v-if="column.dataIndex === 'dict'">
 | 
			
		||||
          <a-tag color="cyan">
 | 
			
		||||
            {{ text && text.length > 0 ? text.map((e) => e.valueName).join(',') : '暂无' }}
 | 
			
		||||
          </a-tag>
 | 
			
		||||
        </template> -->
 | 
			
		||||
 | 
			
		||||
        <template v-if="column.dataIndex === 'action'">
 | 
			
		||||
          <div class="smart-table-operate">
 | 
			
		||||
            <a-button @click="showForm(record)" type="link" v-privilege="'address:update'">
 | 
			
		||||
              <template #icon>
 | 
			
		||||
                <EditOutlined/>
 | 
			
		||||
              </template>
 | 
			
		||||
              编辑
 | 
			
		||||
            </a-button>
 | 
			
		||||
            <a-button @click="onDelete(record)" danger type="link" v-privilege="'address:delete'">
 | 
			
		||||
              <template #icon>
 | 
			
		||||
                <DeleteOutlined/>
 | 
			
		||||
              </template>
 | 
			
		||||
              删除
 | 
			
		||||
            </a-button>
 | 
			
		||||
          </div>
 | 
			
		||||
        </template>
 | 
			
		||||
      </template>
 | 
			
		||||
    </a-table>
 | 
			
		||||
    <!---------- 表格 end ----------->
 | 
			
		||||
 | 
			
		||||
    <div class="smart-query-table-page">
 | 
			
		||||
      <a-pagination
 | 
			
		||||
          showSizeChanger
 | 
			
		||||
          showQuickJumper
 | 
			
		||||
          show-less-items
 | 
			
		||||
          :pageSizeOptions="PAGE_SIZE_OPTIONS"
 | 
			
		||||
          :defaultPageSize="queryForm.pageSize"
 | 
			
		||||
          v-model:current="queryForm.pageNum"
 | 
			
		||||
          v-model:pageSize="queryForm.pageSize"
 | 
			
		||||
          :total="total"
 | 
			
		||||
          @change="queryData"
 | 
			
		||||
          @showSizeChange="queryData"
 | 
			
		||||
          :show-total="(total:number) => `共${total}条`"
 | 
			
		||||
      />
 | 
			
		||||
    </div>
 | 
			
		||||
 | 
			
		||||
    <!--新建/编辑-->
 | 
			
		||||
    <AddressForm ref="formRef" @reloadList="queryData"/>
 | 
			
		||||
 | 
			
		||||
    <!--    导入-->
 | 
			
		||||
    <a-modal v-model:open="importModalShowFlag" title="导入" footer>
 | 
			
		||||
      <div style="text-align: center; width: 400px; margin: 0 auto">
 | 
			
		||||
        <a-button @click="downloadExcel">
 | 
			
		||||
          <download-outlined/>
 | 
			
		||||
          第一步:下载模板
 | 
			
		||||
        </a-button>
 | 
			
		||||
        <br/>
 | 
			
		||||
        <br/>
 | 
			
		||||
        <a-upload
 | 
			
		||||
            v-model:fileList="fileList"
 | 
			
		||||
            name="file"
 | 
			
		||||
            :multiple="false"
 | 
			
		||||
            action="https://www.mocky.io/v2/5cc8019d300000980a055e76"
 | 
			
		||||
            accept=".xls,.xlsx"
 | 
			
		||||
            :before-upload="beforeUpload"
 | 
			
		||||
            @remove="handleRemove"
 | 
			
		||||
        >
 | 
			
		||||
          <a-button>
 | 
			
		||||
            <upload-outlined/>
 | 
			
		||||
            第二步:选择文件
 | 
			
		||||
          </a-button>
 | 
			
		||||
        </a-upload>
 | 
			
		||||
 | 
			
		||||
        <br/>
 | 
			
		||||
        <a-button @click="onImportAddress">
 | 
			
		||||
          <ImportOutlined/>
 | 
			
		||||
          第三步:开始导入
 | 
			
		||||
        </a-button>
 | 
			
		||||
      </div>
 | 
			
		||||
    </a-modal>
 | 
			
		||||
 | 
			
		||||
  </a-card>
 | 
			
		||||
</template>
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
import {reactive, ref, onMounted} from 'vue';
 | 
			
		||||
import {message, Modal} from 'ant-design-vue';
 | 
			
		||||
import {SmartLoading} from '/@/components/framework/smart-loading';
 | 
			
		||||
import {addressApi} from '/@/api/business/base/address/address-api';
 | 
			
		||||
import {PAGE_SIZE_OPTIONS} from '/@/constants/common-const';
 | 
			
		||||
import {smartSentry} from '/@/lib/smart-sentry';
 | 
			
		||||
import TableOperator from '/@/components/support/table-operator/index.vue';
 | 
			
		||||
import AddressForm from '/@/views/business/base/address/address-form.vue';
 | 
			
		||||
import {TABLE_ID_CONST} from "/@/constants/support/table-id-const";
 | 
			
		||||
import AddressSelect from "/@/views/business/base/address/address-select.vue";
 | 
			
		||||
import {fileApi} from "/@/api/support/file-api";
 | 
			
		||||
 | 
			
		||||
// ---------------------------- 表格列 ----------------------------
 | 
			
		||||
 | 
			
		||||
const columns = ref([
 | 
			
		||||
  {
 | 
			
		||||
    title: '收货地址id',
 | 
			
		||||
    dataIndex: 'addressId',
 | 
			
		||||
    ellipsis: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '收货单位',
 | 
			
		||||
    dataIndex: 'name',
 | 
			
		||||
    ellipsis: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '联系人',
 | 
			
		||||
    dataIndex: 'person',
 | 
			
		||||
    ellipsis: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '电话',
 | 
			
		||||
    dataIndex: 'telephone',
 | 
			
		||||
    ellipsis: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '地址',
 | 
			
		||||
    dataIndex: 'address',
 | 
			
		||||
    ellipsis: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '创建时间',
 | 
			
		||||
    dataIndex: 'createTime',
 | 
			
		||||
    ellipsis: true,
 | 
			
		||||
  },
 | 
			
		||||
  {
 | 
			
		||||
    title: '操作',
 | 
			
		||||
    dataIndex: 'action',
 | 
			
		||||
    fixed: 'right',
 | 
			
		||||
    width: 140,
 | 
			
		||||
  },
 | 
			
		||||
]);
 | 
			
		||||
 | 
			
		||||
// ---------------------------- 查询数据表单和方法 ----------------------------
 | 
			
		||||
 | 
			
		||||
const queryFormState = {
 | 
			
		||||
  addressId: undefined, //收货单位
 | 
			
		||||
  pageNum: 1,
 | 
			
		||||
  pageSize: 10,
 | 
			
		||||
};
 | 
			
		||||
// 查询表单form
 | 
			
		||||
const queryForm = reactive({...queryFormState});
 | 
			
		||||
// 表格加载loading
 | 
			
		||||
const tableLoading = ref(false);
 | 
			
		||||
// 表格数据
 | 
			
		||||
const tableData = ref([]);
 | 
			
		||||
// 总数
 | 
			
		||||
const total = ref(0);
 | 
			
		||||
 | 
			
		||||
// 重置查询条件
 | 
			
		||||
function resetQuery() {
 | 
			
		||||
  let pageSize = queryForm.pageSize;
 | 
			
		||||
  Object.assign(queryForm, queryFormState);
 | 
			
		||||
  queryForm.pageSize = pageSize;
 | 
			
		||||
  queryData();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 搜索
 | 
			
		||||
function onSearch() {
 | 
			
		||||
  queryForm.pageNum = 1;
 | 
			
		||||
  queryData();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//选择收货单位
 | 
			
		||||
function changeAddressSelect(selectValue: any) {
 | 
			
		||||
  if (selectValue) {
 | 
			
		||||
    queryForm.addressId = selectValue.addressId;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 查询数据
 | 
			
		||||
async function queryData() {
 | 
			
		||||
  tableLoading.value = true;
 | 
			
		||||
  try {
 | 
			
		||||
    let queryResult = await addressApi.queryPage(queryForm);
 | 
			
		||||
    tableData.value = queryResult.data.list;
 | 
			
		||||
    total.value = queryResult.data.total;
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    smartSentry.captureError(e);
 | 
			
		||||
  } finally {
 | 
			
		||||
    tableLoading.value = false;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
onMounted(queryData);
 | 
			
		||||
 | 
			
		||||
// ---------------------------- 添加/修改 ----------------------------
 | 
			
		||||
const formRef = ref();
 | 
			
		||||
 | 
			
		||||
function showForm(data) {
 | 
			
		||||
  formRef.value.show(data);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ---------------------------- 单个删除 ----------------------------
 | 
			
		||||
//确认删除
 | 
			
		||||
function onDelete(data) {
 | 
			
		||||
  Modal.confirm({
 | 
			
		||||
    title: '提示',
 | 
			
		||||
    content: '确定要删除选吗?',
 | 
			
		||||
    okText: '删除',
 | 
			
		||||
    okType: 'danger',
 | 
			
		||||
    onOk() {
 | 
			
		||||
      requestDelete(data);
 | 
			
		||||
    },
 | 
			
		||||
    cancelText: '取消',
 | 
			
		||||
    onCancel() {
 | 
			
		||||
    },
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//请求删除
 | 
			
		||||
async function requestDelete(data) {
 | 
			
		||||
  SmartLoading.show();
 | 
			
		||||
  try {
 | 
			
		||||
    await addressApi.delete(data.addressId);
 | 
			
		||||
    message.success('删除成功');
 | 
			
		||||
    await queryData();
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    smartSentry.captureError(e);
 | 
			
		||||
  } finally {
 | 
			
		||||
    SmartLoading.hide();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ---------------------------- 批量删除 ----------------------------
 | 
			
		||||
 | 
			
		||||
// 选择表格行
 | 
			
		||||
const selectedRowKeyList = ref([]);
 | 
			
		||||
 | 
			
		||||
function onSelectChange(selectedRowKeys) {
 | 
			
		||||
  selectedRowKeyList.value = selectedRowKeys;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 批量删除
 | 
			
		||||
function confirmBatchDelete() {
 | 
			
		||||
  Modal.confirm({
 | 
			
		||||
    title: '提示',
 | 
			
		||||
    content: '确定要批量删除这些数据吗?',
 | 
			
		||||
    okText: '删除',
 | 
			
		||||
    okType: 'danger',
 | 
			
		||||
    onOk() {
 | 
			
		||||
      requestBatchDelete();
 | 
			
		||||
    },
 | 
			
		||||
    cancelText: '取消',
 | 
			
		||||
    onCancel() {
 | 
			
		||||
    },
 | 
			
		||||
  });
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//请求批量删除
 | 
			
		||||
async function requestBatchDelete() {
 | 
			
		||||
  try {
 | 
			
		||||
    SmartLoading.show();
 | 
			
		||||
    await addressApi.batchDelete(selectedRowKeyList.value);
 | 
			
		||||
    message.success('删除成功');
 | 
			
		||||
    await queryData();
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    smartSentry.captureError(e);
 | 
			
		||||
  } finally {
 | 
			
		||||
    SmartLoading.hide();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ------------------------------- 导出和导入 ---------------------------------
 | 
			
		||||
// 导入弹窗
 | 
			
		||||
const importModalShowFlag = ref(false);
 | 
			
		||||
 | 
			
		||||
const fileList = ref<UploadFile[]>([])
 | 
			
		||||
 | 
			
		||||
// 显示导入
 | 
			
		||||
function showImportModal() {
 | 
			
		||||
  fileList.value = [];
 | 
			
		||||
  importModalShowFlag.value = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//下载模板
 | 
			
		||||
async function downloadExcel() {
 | 
			
		||||
  try {
 | 
			
		||||
    //默认地址模板fileKey
 | 
			
		||||
    let fileKey = 'public/common/c651410627d9447ba9a8ae070bf911e5_20250324180257.xlsx';
 | 
			
		||||
    fileApi.downLoadFile(fileKey);
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    smartSentry.captureError(e);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 移除文件
 | 
			
		||||
function handleRemove(file: UploadFile) {
 | 
			
		||||
  const index = fileList.value.indexOf(file);
 | 
			
		||||
  const newFileList = fileList.value.slice();
 | 
			
		||||
  newFileList.splice(index, 1);
 | 
			
		||||
  fileList.value = newFileList;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 上传文件
 | 
			
		||||
function beforeUpload(file: UploadFile) {
 | 
			
		||||
  fileList.value = [...(fileList.value || []), file];
 | 
			
		||||
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//导入
 | 
			
		||||
async function onImportAddress() {
 | 
			
		||||
  if (fileList.value.length === 0) {
 | 
			
		||||
    return message.error('请选择文件');
 | 
			
		||||
  }
 | 
			
		||||
  const formData = new FormData();
 | 
			
		||||
  fileList.value.forEach((file: UploadFile) => {
 | 
			
		||||
    formData.append('file', file.originFileObj!);
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
  SmartLoading.show();
 | 
			
		||||
  try {
 | 
			
		||||
    const response = await addressApi.importAddress(formData);
 | 
			
		||||
    const {success} = JSON.parse(response.msg);
 | 
			
		||||
    message.success(success);
 | 
			
		||||
    importModalShowFlag.value = false;
 | 
			
		||||
    await queryData();
 | 
			
		||||
  } catch (e) {
 | 
			
		||||
    smartSentry.captureError(e);
 | 
			
		||||
  } finally {
 | 
			
		||||
    SmartLoading.hide();
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//导出
 | 
			
		||||
function onExportAddress() {
 | 
			
		||||
  addressApi.exportAddress();
 | 
			
		||||
}
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,89 @@
 | 
			
		|||
<!--
 | 
			
		||||
  * 收货地址 下拉选择框
 | 
			
		||||
  *
 | 
			
		||||
  *
 | 
			
		||||
-->
 | 
			
		||||
<template>
 | 
			
		||||
  <a-select
 | 
			
		||||
      v-model:value="selectValue"
 | 
			
		||||
      :style="`width: ${width}`"
 | 
			
		||||
      :placeholder="props.placeholder"
 | 
			
		||||
      :showSearch="true"
 | 
			
		||||
      :allowClear="true"
 | 
			
		||||
      :size="size"
 | 
			
		||||
      @change="handleChange"
 | 
			
		||||
      :disabled="disabled"
 | 
			
		||||
      :mode="multiple ? 'multiple' : ''"
 | 
			
		||||
      optionFilterProp="label"
 | 
			
		||||
  >
 | 
			
		||||
    <a-select-option v-for="address in addressList" :key="address.addressId" :label="address.name">
 | 
			
		||||
      {{ address.name }}
 | 
			
		||||
    </a-select-option>
 | 
			
		||||
  </a-select>
 | 
			
		||||
</template>
 | 
			
		||||
 | 
			
		||||
<script setup lang="ts">
 | 
			
		||||
import {onMounted, ref, watch} from 'vue';
 | 
			
		||||
import {addressApi} from "/@/api/business/base/address/address-api";
 | 
			
		||||
 | 
			
		||||
const props = defineProps({
 | 
			
		||||
  value: [Number, String, Object, Array],
 | 
			
		||||
  width: {
 | 
			
		||||
    type: String,
 | 
			
		||||
    default: '200px',
 | 
			
		||||
  },
 | 
			
		||||
  placeholder: {
 | 
			
		||||
    type: String,
 | 
			
		||||
    default: '请选择',
 | 
			
		||||
  },
 | 
			
		||||
  size: {
 | 
			
		||||
    type: String,
 | 
			
		||||
    default: 'default',
 | 
			
		||||
  },
 | 
			
		||||
  disabled: {
 | 
			
		||||
    type: Boolean,
 | 
			
		||||
    default: false,
 | 
			
		||||
  },
 | 
			
		||||
  multiple: {
 | 
			
		||||
    type: Boolean,
 | 
			
		||||
    default: false,
 | 
			
		||||
  },
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
const addressList = ref([]);
 | 
			
		||||
 | 
			
		||||
async function queryData() {
 | 
			
		||||
  let res = await addressApi.queryAddress({});
 | 
			
		||||
  addressList.value = res.data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const emit = defineEmits(['update:value', 'change']);
 | 
			
		||||
 | 
			
		||||
const selectValue = ref(props.value);
 | 
			
		||||
 | 
			
		||||
// 箭头value变化
 | 
			
		||||
watch(
 | 
			
		||||
    () => props.value,
 | 
			
		||||
    (newValue) => {
 | 
			
		||||
      selectValue.value = newValue;
 | 
			
		||||
    }
 | 
			
		||||
);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
function handleChange(value: any) {
 | 
			
		||||
  let selectedAddress: any[] | any;
 | 
			
		||||
  if (Array.isArray(value)) {
 | 
			
		||||
    // 多选情况
 | 
			
		||||
    selectedAddress = value.map((id) => addressList.value.find((item: any) => item.addressId === id)).filter(Boolean);
 | 
			
		||||
  } else {
 | 
			
		||||
    // 单选情况
 | 
			
		||||
    selectedAddress = addressList.value.find((item: any) => item.addressId === value);
 | 
			
		||||
  }
 | 
			
		||||
  emit('update:value', value);
 | 
			
		||||
  emit('change', selectedAddress);
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
onMounted(queryData);
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			@ -77,9 +77,9 @@
 | 
			
		|||
<!--
 | 
			
		||||
  * {{ formData.description }}
 | 
			
		||||
  *
 | 
			
		||||
  * @Author:     {{ formData.frontAuthor }}
 | 
			
		||||
  * @Date:       {{ formData.frontDate }}
 | 
			
		||||
  * @Copyright   {{ formData.copyright }}
 | 
			
		||||
  * @author:     {{ formData.frontAuthor }}
 | 
			
		||||
  * @since:       {{ formData.frontDate }}
 | 
			
		||||
  * copyright   {{ formData.copyright }}
 | 
			
		||||
--></pre
 | 
			
		||||
            >
 | 
			
		||||
          </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -89,9 +89,9 @@
 | 
			
		|||
/*
 | 
			
		||||
 * {{ formData.description }}
 | 
			
		||||
 *
 | 
			
		||||
 * @Author:     {{ formData.frontAuthor }}
 | 
			
		||||
 * @Date:       {{ formData.frontDate }}
 | 
			
		||||
 * @Copyright   {{ formData.copyright }}
 | 
			
		||||
 * @author:     {{ formData.frontAuthor }}
 | 
			
		||||
 * @since:       {{ formData.frontDate }}
 | 
			
		||||
 * copyright   {{ formData.copyright }}
 | 
			
		||||
 */
 | 
			
		||||
              </pre
 | 
			
		||||
            >
 | 
			
		||||
| 
						 | 
				
			
			@ -122,9 +122,9 @@
 | 
			
		|||
/**
 | 
			
		||||
 * {{ formData.description }}
 | 
			
		||||
 *
 | 
			
		||||
 * @Author:     {{ formData.backendAuthor }}
 | 
			
		||||
 * @Date:       {{ formData.backendDate }}
 | 
			
		||||
 * @Copyright   {{ formData.copyright }}
 | 
			
		||||
 * @author:     {{ formData.backendAuthor }}
 | 
			
		||||
 * @since:       {{ formData.backendDate }}
 | 
			
		||||
 * copyright   {{ formData.copyright }}
 | 
			
		||||
 */
 | 
			
		||||
              </pre
 | 
			
		||||
            >
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue