123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857 |
- <template>
- <div class="tenant">
- <!-- <Banner /> -->
- <div class="content">
- <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" highlight-current-row
- :selectConfig="selectConfig" :table-events="{
- //element talbe事件都能传
- select: select,
- }" :action-list="[
- {
- text: '添加订单',
- action: () => openModal('add'),
- },
- ]" @get-list="getList">
- <template #code="{ item }">
- <div style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
- {{ item.code }}
- </div>
- </template>
- <template #status="{ item }">
- <div style="cursor: pointer; color: #409eff" @click="handleClickStatus(item)">
- {{ dictValueLabel(item.status, statusData) }}
- </div>
- </template>
- <template #address="{ item }">
- <div>
- {{ item.countryName }}, {{ item.provinceName }} ,
- {{ item.cityName }}, {{ item.detailedAddress }}
- </div>
- </template>
- </byTable>
- </div>
- <el-dialog :title="modalType == 'add' ? '添加订单' : '调仓接收'" v-model="dialogVisible" width="80%" v-loading="loading">
- <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="byform">
- <template #countryId>
- <div style="width:100%">
- <el-select v-model="formData.data.countryId" placeholder="国家" style="width:100%" @change="(val) => getCityData(val, '20', true)">
- <el-option v-for="item in countryData" :label="item.chineseName" :value="item.id">
- </el-option>
- </el-select>
- </div>
- </template>
- <template #provinceId>
- <div style="width:100%">
- <selectCity placeholder="省/洲" @change="(val) => getCityData(val, '30', true)" addressId="provinceId" addressName="provinceName"
- v-model="formData.data" :data="provinceData">
- </selectCity>
- </div>
- </template>
- <template #cityId>
- <div style="width:100%">
- <selectCity placeholder="城市" addressId="cityId" addressName="cityName" v-model="formData.data" :data="cityData">
- </selectCity>
- </div>
- </template>
- <template #products>
- <div style="width: 100%">
- <el-button type="primary" @click="openProduct = true" style="margin-bottom: 10px">
- 添加产品
- </el-button>
- <el-button type="primary" @click="openExcel = true" style="margin-bottom: 10px">
- excel导入
- </el-button>
- <el-table :data="formData.data.orderDetailsList" show-summary :summary-method="getSummaries">
- <el-table-column prop="productCode" label="产品编码" width="150" />
- <el-table-column prop="productName" label="产品名称" min-width="150" />
- <el-table-column prop="price" label="单价" width="150">
- <template #default="{ row, $index }">
- <el-form-item :prop="'orderDetailsList.' + $index + '.price'" :rules="rules.price" :inline-message="true">
- <el-input-number v-model="row.price" :precision="4" :controls="false" :min="0" @change="totalAmount" placeholder="请输入"
- onmousewheel="return false;" />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="quantity" label="数量" width="150">
- <template #default="{ row, $index }">
- <el-form-item :prop="'orderDetailsList.' + $index + '.quantity'" :rules="rules.quantity" :inline-message="true">
- <el-input-number v-model="row.quantity" :precision="4" :controls="false" :min="0" @change="totalAmount" placeholder="请输入"
- onmousewheel="return false;" />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="total" label="小计" width="120" />
- <el-table-column prop="remark" label="备注" min-width="200">
- <template #default="{ row, $index }">
- <el-form-item :prop="'orderDetailsList.' + $index + '.remark'" :rules="rules.remark" :inline-message="true">
- <el-input v-model="row.remark" placeholder="请输入" />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="zip" label="操作" width="60" fixed="right" align="center">
- <template #default="{ $index }">
- <el-button type="primary" link @click="handleRemove($index)">删除</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="dialogVisible = false" size="large">取 消</el-button>
- <el-button type="primary" @click="submitForm('byform')" size="large" :loading="submitLoading">
- 确 定
- </el-button>
- </template>
- </el-dialog>
- <el-dialog v-model="openExcel" title="excel导入" width="30%" append-to-body>
- <div v-loading="excelLoading">
- <div style="margin: 15px 0">
- <el-button @click="downloadTemplate" type="primary">Excel模板下载</el-button>
- </div>
- <el-upload :action="actionUrl + '/orderInfo/excelImport'" :headers="headers" :before-upload="useImportExcelStore().updateRequestHeaders"
- :on-success="handleSuccess" :on-progress="handleProgress" :show-file-list="false" :on-error="handleError" accept=".xls, .xlsx">
- <el-button type="primary" plain>点击导入</el-button>
- </el-upload>
- </div>
- <template #footer>
- <el-button @click="openExcel = false" size="large">取 消</el-button>
- </template>
- </el-dialog>
- <el-dialog v-model="openProduct" title="选择产品" width="70%" append-to-body>
- <SelectProduct @handleSelect="handleSelect"></SelectProduct>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="openProduct = false">取消</el-button>
- </span>
- </template>
- </el-dialog>
- <el-dialog v-model="openDetails" title="订单详情" width="40%" append-to-body>
- <OrderDetails :orderData="formData.orderData" :key="formData.orderData.id"></OrderDetails>
- <template #footer>
- <span class="dialog-footer">
- <el-button @click="openDetails = false">取消</el-button>
- </span>
- </template>
- </el-dialog>
- <el-dialog :title="'查看'" v-model="recordDialog" width="900" destroy-on-close>
- <byForm :formConfig="recordFormConfig" :formOption="recordFormOption" v-model="recordFormData.data">
- <template #products>
- <div style="width: 100%">
- <el-table :data="recordFormData.data.list">
- <el-table-column prop="logisticsCompanyName" label="物流/快递公司" />
- <el-table-column prop="code" label="物流/快递单号" />
- <el-table-column prop="logisticsStatus" label="物流状态" width="100" :formatter="(row) => handleShowKdStatus(row.logisticsStatus)" />
- <el-table-column prop="createTime" label="创建时间" width="155" />
- <el-table-column label="操作" width="90" align="center">
- <template #default="{ row, $index }">
- <el-button type="primary" text @click="pushKdRoute(row)">查看</el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- </byForm>
- <template #footer>
- <el-button @click="recordDialog = false" size="large">取 消</el-button>
- </template>
- </el-dialog>
- </div>
- </template>
-
- <script setup>
- /* eslint-disable vue/no-unused-components */
- import { ElMessage, ElMessageBox } from "element-plus";
- import byTable from "@/components/byTable/index";
- import byForm from "@/components/byForm/index";
- import { computed, defineComponent, ref } from "vue";
- import useUserStore from "@/store/modules/user";
- import SelectProduct from "@/components/WDLY/product/SelectProduct";
- import OrderDetails from "@/components/WDLY/order/details";
- import selectCity from "@/components/selectCity/index.vue";
- import useImportExcelStore from "@/store/modules/importExcel";
- const headers = computed(() => useImportExcelStore().requestHeaders);
- const actionUrl = import.meta.env.VITE_APP_BASE_API;
- const loading = ref(false);
- const submitLoading = ref(false);
- const sourceList = ref({
- data: [],
- pagination: {
- total: 3,
- pageNum: 1,
- pageSize: 10,
- },
- });
- let dialogVisible = ref(false);
- let openProduct = ref(false);
- let openDetails = ref(false);
- let roomDialogVisible = ref(false);
- let modalType = ref("add");
- let rules = ref({
- customerInfoId: [
- {
- required: true,
- message: "请选择客户",
- trigger: "change",
- },
- ],
- type: [
- {
- required: true,
- message: "请选择订单类型",
- trigger: "change",
- },
- ],
- // countryId: [
- // {
- // required: true,
- // message: "请选择国家",
- // trigger: "change",
- // },
- // ],
- // provinceId: [
- // {
- // required: true,
- // message: "请选择省/洲",
- // trigger: "change",
- // },
- // ],
- // cityId: [
- // {
- // required: true,
- // message: "请选择城市",
- // trigger: "change",
- // },
- // ],
- // contacts: [
- // {
- // required: true,
- // message: "请输入姓名",
- // trigger: "blur",
- // },
- // ],
- // phone: [
- // {
- // required: true,
- // message: "请输入联系电话",
- // trigger: "blur",
- // },
- // ],
- detailedAddress: [
- {
- required: true,
- message: "请输入详细地址",
- trigger: "blur",
- },
- ],
- price: [
- {
- required: true,
- message: "请输入单价",
- trigger: "blur",
- },
- ],
- quantity: [
- {
- required: true,
- message: "请输入数量",
- trigger: "blur",
- },
- ],
- });
- const { proxy } = getCurrentInstance();
- const statusData = [
- {
- label: "进行中",
- value: "1",
- },
- {
- label: "已完成",
- value: "2",
- },
- {
- label: "已取消",
- value: "3",
- },
- ];
- const selectConfig = reactive([
- {
- label: "订单类型",
- prop: "type",
- data: [],
- },
- {
- label: "订单状态",
- prop: "status",
- data: statusData,
- },
- ]);
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "订单类型",
- prop: "type",
- },
- render(type) {
- return proxy.dictDataEcho(type, salesType.value);
- },
- },
- {
- attrs: {
- label: "订单编号",
- prop: "code",
- slot: "code",
- },
- },
- {
- attrs: {
- label: "客户名称",
- prop: "customerName",
- },
- },
- {
- attrs: {
- label: "订单金额",
- prop: "amountMoney",
- },
- render(money) {
- return proxy.moneyFormat(money, 4);
- },
- },
- {
- attrs: {
- label: "收件人",
- prop: "contacts",
- },
- },
- {
- attrs: {
- label: "联系电话",
- prop: "phone",
- },
- },
- {
- attrs: {
- label: "收件城市",
- prop: "address",
- slot: "address",
- },
- },
- {
- attrs: {
- label: "下单时间",
- prop: "createTime",
- },
- },
- {
- attrs: {
- label: "订单状态",
- prop: "status",
- slot: "status",
- },
- },
- {
- attrs: {
- label: "操作",
- width: "200",
- align: "right",
- },
- // 渲染 el-button,一般用在最后一列。
- renderHTML(row) {
- return [
- row.status == 1
- ? {
- attrs: {
- label: "结束",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- getDtl(row, 2);
- },
- }
- : {},
- row.status == 1
- ? {
- attrs: {
- label: "取消",
- type: "primary",
- text: true,
- },
- el: "button",
- click() {
- getDtl(row, 3);
- },
- }
- : {},
- ];
- },
- },
- ];
- });
- let formData = reactive({
- data: {},
- treeData: [],
- orderData: {},
- });
- const formOption = reactive({
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const byform = ref(null);
- const treeData = ref([]);
- const formConfig = reactive([
- {
- type: "select",
- prop: "customerInfoId",
- label: "客户名称",
- isLoad: {
- url: "/customer/page",
- req: {
- pageNum: 1,
- pageSize: 9999,
- },
- labelKey: "name",
- labelVal: "id",
- method: "post",
- resUrl: "rows",
- },
- style: {
- width: "31.5%",
- },
- },
- {
- type: "select",
- prop: "type",
- label: "订单类型",
- itemWidth: 100,
- data: [],
- style: {
- width: "31.5%",
- },
- },
- {
- type: "input",
- prop: "contacts",
- label: "收件人",
- itemWidth: 33.33,
- placeholder: "姓名",
- },
- {
- type: "input",
- prop: "phone",
- label: " ",
- itemWidth: 66,
- placeholder: "联系电话",
- style: {
- width: "48%",
- },
- },
- {
- type: "slot",
- slotName: "countryId",
- prop: "countryId",
- label: "地址",
- itemWidth: 33.33,
- },
- {
- type: "slot",
- slotName: "provinceId",
- label: " ",
- itemWidth: 33.33,
- },
- {
- type: "slot",
- slotName: "cityId",
- prop: "cityId",
- label: " ",
- itemWidth: 33.33,
- },
- {
- type: "input",
- itemType: "textarea",
- prop: "detailedAddress",
- },
- {
- type: "title",
- title: "订单明细",
- },
- {
- type: "slot",
- slotName: "products",
- },
- {
- type: "input",
- prop: "amountMoney",
- label: "订单金额",
- disabled: true,
- itemWidth: 20,
- },
- ]);
- const getList = async (req) => {
- sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
- loading.value = true;
- proxy.post("/orderInfo/page", sourceList.value.pagination).then((message) => {
- sourceList.value.data = message.rows;
- sourceList.value.pagination.total = message.total;
- setTimeout(() => {
- loading.value = false;
- }, 200);
- });
- };
- const openModal = () => {
- dialogVisible.value = true;
- modalType.value = "add";
- formData.data = {
- orderDetailsList: [],
- countryId: "44",
- };
- getCityData(formData.data.countryId, "20");
- };
- const submitForm = () => {
- byform.value.handleSubmit((valid) => {
- const list = formData.data.orderDetailsList;
- if (!list.length > 0)
- return ElMessage({
- message: `请添加订单明细!`,
- type: "info",
- });
- for (let i = 0; i < list.length; i++) {
- const e = list[i];
- if (e.quantity == 0) {
- return ElMessage({
- message: `数量不能为0!`,
- type: "info",
- });
- }
- }
- submitLoading.value = true;
- proxy.post("/orderInfo/" + modalType.value, formData.data).then(
- (res) => {
- ElMessage({
- message: modalType.value == "add" ? "添加成功" : "编辑成功",
- type: "success",
- });
- dialogVisible.value = false;
- submitLoading.value = false;
- getList();
- },
- (err) => (submitLoading.value = false)
- );
- });
- };
- const getDtl = (row, status) => {
- const statusNmae = status == 2 ? "结束" : "取消";
- // 弹窗提示是否删除
- ElMessageBox.confirm(`您确定执行${statusNmae}操作吗?`, "提示", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning",
- }).then(() => {
- // 删除
- proxy
- .post("/orderInfo/edit", {
- id: row.id,
- status,
- })
- .then((res) => {
- ElMessage({
- message: "操作成功",
- type: "success",
- });
- getList();
- });
- });
- };
- const warehouseList = ref([]);
- const salesType = ref([]);
- const getDict = () => {
- proxy.getDict(["order_sales_type"]).then((res) => {
- salesType.value = res["order_sales_type"];
- formConfig[1].data = salesType.value.map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- selectConfig[0].data = salesType.value.map((x) => ({
- label: x.dictValue,
- value: x.dictKey,
- }));
- });
- };
- const countryData = ref([]);
- const provinceData = ref([]);
- const cityData = ref([]);
- const getCityData = (id, type, flag) => {
- proxy.post("/customizeArea/list", { parentId: id }).then((res) => {
- if (type === "20") {
- provinceData.value = res;
- if (flag) {
- formData.data.provinceId = "";
- formData.data.provinceName = "";
- formData.data.cityId = "";
- formData.data.cityName = "";
- }
- } else if (type === "30") {
- cityData.value = res;
- if (flag) {
- formData.data.cityId = "";
- formData.data.cityName = "";
- }
- } else {
- countryData.value = res;
- }
- });
- };
- getCityData("0");
- getList();
- getDict();
- const totalAmount = () => {
- let sum = 0;
- for (let i = 0; i < formData.data.orderDetailsList.length; i++) {
- const e = formData.data.orderDetailsList[i];
- e.total = (e.price * 1000000 * e.quantity) / 1000000;
- sum += e.total;
- }
- formData.data.amountMoney = sum;
- };
- const handleSelect = (row) => {
- const flag = formData.data.orderDetailsList.some(
- (x) => x.productId === row.id
- );
- if (flag)
- return ElMessage({
- message: "该物品已选择",
- type: "info",
- });
- formData.data.orderDetailsList.push({
- productName: row.name,
- productCode: row.code,
- productId: row.id,
- total: "",
- quantity: null,
- price: null,
- });
- return ElMessage({
- message: "选择成功",
- type: "success",
- });
- };
- const handleRemove = (index) => {
- formData.data.orderDetailsList.splice(index, 1);
- totalAmount();
- return ElMessage({
- message: "删除成功",
- type: "success",
- });
- };
- const handleClickCode = (row) => {
- formData.orderData = row;
- openDetails.value = true;
- };
- const kdStatusData = ref([
- {
- label: "在途",
- value: "0",
- },
- {
- label: "揽收",
- value: "1",
- },
- {
- label: "疑难",
- value: "2",
- },
- {
- label: "签收",
- value: "3",
- },
- {
- label: "退签",
- value: "4",
- },
- {
- label: "派件",
- value: "5",
- },
- {
- label: "退回",
- value: "6",
- },
- {
- label: "转投",
- value: "7",
- },
- {
- label: "清关",
- value: "8",
- },
- {
- label: "拒签",
- value: "14",
- },
- {
- label: "完成",
- value: "15",
- },
- ]);
- const recordDialog = ref(false);
- const recordFormOption = reactive({
- disabled: false,
- inline: true,
- labelWidth: 100,
- itemWidth: 100,
- rules: [],
- });
- const recordFormConfig = reactive([
- {
- type: "title",
- title: "物流数据",
- },
- {
- type: "slot",
- slotName: "products",
- },
- ]);
- const recordFormData = reactive({
- data: {
- list: [],
- },
- });
- const handleClickStatus = (row) => {
- recordDialog.value = true;
- proxy.post("/orderInfo/getLogisticsInfo", { id: row.id }).then((res) => {
- recordFormData.data.list = res;
- });
- };
- const handleShowKdStatus = (status) => {
- const current = kdStatusData.value.find((x) => x.value === status);
- if (current && current.label) {
- return current.label;
- } else {
- return "异常";
- }
- };
- const pushKdRoute = (row) => {
- proxy.$router.push({
- name: "Logistics",
- query: {
- keyword: row.code,
- },
- });
- };
- const getSummaries = (param) => {
- const { columns, data } = param; //columns是每列的信息,data是每行的信息
- const sums = [];
- columns.forEach((column, index) => {
- if (index === 0) {
- sums[index] = "合计"; //此处是在index=0的这一列显示为“合计”
- return;
- }
- const values = data.map((item) => Number(item[column.property]));
- if (column.property === "quantity" || column.property === "total") {
- sums[index] = values.reduce((prev, curr) => {
- const value = Number(curr);
- if (!isNaN(value)) {
- return Number(parseFloat(prev + curr).toFixed(4));
- } else {
- return prev;
- }
- }, 0);
- sums[index];
- }
- });
- return sums;
- };
- const openExcel = ref(false);
- const excelLoading = ref(false);
- const downloadTemplate = () => {
- fetch("/static/SaleOrderImportTemplate.xlsx")
- .then((res) => res.blob())
- .then((res) => {
- const url = window.URL.createObjectURL(res);
- let filename = "销售订单导入模板.xlsx";
- const link = document.createElement("a");
- link.style.display = "none";
- link.href = url;
- link.setAttribute("download", filename);
- document.body.appendChild(link);
- link.click();
- });
- };
- const handleProgress = () => {
- excelLoading.value = true;
- };
- const handleSuccess = (res) => {
- if (res.code != 200) {
- excelLoading.value = false;
- return ElMessage({
- message: `${res.msg},请重试!`,
- type: "info",
- });
- } else {
- ElMessage({
- message: "导入成功!",
- type: "success",
- });
- if (res && res.data && res.data.length > 0) {
- formData.data.orderDetailsList = res.data.map((x) => ({
- productName: x.productName,
- productCode: x.productCustomCode,
- productId: x.bussinessId,
- total: "",
- quantity: x.count,
- price: x.price,
- remark: x.remark,
- }));
- totalAmount();
- }
- openExcel.value = false;
- excelLoading.value = false;
- }
- };
- const handleError = (err) => {
- ElMessage({
- message: `${err},请重试!`,
- type: "info",
- });
- openExcel.value = false;
- excelLoading.value = false;
- };
- </script>
-
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- </style>
|