1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006 |
- <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: 'Excel导入',
- action: () => openExcel(),
- disabled: false,
- },
- {
- text: '添加订单',
- action: () => openModal('add'),
- },
- ]"
- @get-list="getList"
- >
- <template #code="{ item }">
- <div
- style="cursor: pointer; color: #409eff"
- @click="handleClickCode(item)"
- >
- {{ item.code }}
- </div>
- </template>
- <template #address="{ item }">
- <div>
- {{ item.countryName }}, {{ item.provinceName }} ,
- {{ item.cityName }}
- </div>
- </template>
- <template #status="{ item }">
- <div
- style="cursor: pointer; color: #409eff"
- @click="handleClickStatus(item)"
- >
- {{ dictValueLabel(item.status, outboundType) }}
- </div>
- </template>
- </byTable>
- </div>
- <el-dialog
- :title="modalType == 'add' ? '添加订单' : '调仓接收'"
- v-model="dialogVisible"
- width="800"
- v-loading="loading"
- >
- <byForm
- :formConfig="formConfig"
- :formOption="formOption"
- v-model="formData.data"
- :rules="rules"
- ref="byform"
- >
- <template #distributionCenter>
- <div>
- <el-autocomplete
- v-model="formData.data.distributionCenter"
- :fetch-suggestions="querySearchPerson"
- clearable
- class="inline-input w-50"
- placeholder="请输入"
- @select="handlePerson"
- >
- </el-autocomplete>
- </div>
- </template>
- <template #countryId>
- <div>
- <el-select
- v-model="formData.data.countryId"
- placeholder="国家"
- @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>
- <selectCity
- placeholder="省/洲"
- @change="(val) => getCityData(val, '30', true)"
- addressId="provinceId"
- addressName="provinceName"
- v-model="formData.data"
- :data="provinceData"
- >
- </selectCity>
- </div>
- </template>
- <template #cityId>
- <div>
- <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-table
- :data="formData.data.jdOrderDetailsList"
- show-summary
- :summary-method="getSummaries"
- >
- <el-table-column prop="productCode" label="产品编码" />
- <el-table-column prop="productName" label="产品名称" />
- <el-table-column prop="price" label="单价" min-width="150">
- <template #default="{ row, $index }">
- <el-form-item
- :prop="'jdOrderDetailsList.' + $index + '.price'"
- :rules="rules.price"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.price"
- :precision="4"
- :controls="false"
- :min="0"
- @change="totalAmount"
- onmousewheel="return false;"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="quantity" label="数量" min-width="150">
- <template #default="{ row, $index }">
- <el-form-item
- :prop="'jdOrderDetailsList.' + $index + '.quantity'"
- :rules="rules.quantity"
- :inline-message="true"
- >
- <el-input-number
- v-model="row.quantity"
- :precision="4"
- :controls="false"
- :min="0"
- @change="totalAmount"
- onmousewheel="return false;"
- />
- </el-form-item>
- </template>
- </el-table-column>
- <el-table-column prop="total" label="小计" />
- <el-table-column prop="remark" label="备注" min-width="200">
- <template #default="{ row, $index }">
- <el-form-item
- :prop="'jdOrderDetailsList.' + $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="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="Excel导入"
- v-model="openExcelDialog"
- width="400"
- v-loading="excelLoading"
- >
- <div style="margin-bottom: 10px">导入前请先选择客户</div>
- <el-select v-model="importData.customerId" placeholder="请选择客户">
- <el-option
- v-for="item in warehouseList"
- :key="item.id"
- :label="item.name"
- :value="item.id"
- />
- </el-select>
- <div style="margin-top: 20px" v-show="importData.customerId">
- <div style="margin-bottom: 10px">上传附件</div>
- <el-upload
- :action="actionUrl + '/jdOrder/excelImport'"
- :data="importData"
- :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">选择</el-button>
- </el-upload>
- </div>
- <template #footer>
- <el-button @click="openExcelDialog = false">取 消</el-button>
- </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 { getToken } from "@/utils/auth";
- 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);
- const importData = reactive({});
- let roomDialogVisible = ref(false);
- let excelLoading = ref(false);
- let modalType = ref("add");
- let rules = ref({
- customerId: [
- {
- 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",
- // },
- // ],
- code: [
- {
- required: true,
- message: "请输入订单编号",
- trigger: "blur",
- },
- ],
- contactPerson: [
- {
- required: true,
- message: "请输入收货负责人",
- trigger: "blur",
- },
- ],
- contactNumber: [
- {
- required: true,
- message: "请输入收货电话",
- trigger: "blur",
- },
- ],
- detailedAddress: [
- {
- required: true,
- message: "请输入详细地址",
- trigger: "blur",
- },
- ],
- price: [
- {
- required: true,
- message: "请输入单价",
- trigger: "blur",
- },
- ],
- quantity: [
- {
- required: true,
- message: "请输入数量",
- trigger: "blur",
- },
- ],
- distributionCenter: [
- {
- required: true,
- message: "请输入/选择配送中心",
- trigger: "blur",
- },
- ],
- });
- const { proxy } = getCurrentInstance();
- const outboundType = ref([
- {
- label: "未出库",
- value: "1",
- },
- {
- label: "部分出库",
- value: "2",
- },
- {
- label: "已出库",
- value: "3",
- },
- ]);
- const selectConfig = reactive([
- {
- label: "入库状态",
- prop: "status",
- data: outboundType.value,
- },
- ]);
- const config = computed(() => {
- return [
- {
- attrs: {
- label: "订单编号",
- prop: "code",
- },
- },
- {
- attrs: {
- label: "客户名称",
- prop: "customerName",
- },
- },
- {
- attrs: {
- label: "配送中心",
- prop: "distributionCenter",
- },
- },
- {
- attrs: {
- label: "所在城市",
- prop: "address",
- slot: "address",
- },
- },
- {
- attrs: {
- label: "详细地址",
- prop: "detailedAddress",
- },
- },
- {
- attrs: {
- label: "收货负责人",
- prop: "contactPerson",
- },
- },
- {
- attrs: {
- label: "收货电话",
- prop: "contactNumber",
- },
- },
- {
- attrs: {
- label: "订单金额",
- prop: "amount",
- },
- render(amount) {
- return proxy.moneyFormat(amount, 2);
- },
- },
- {
- attrs: {
- label: "出库状态",
- prop: "status",
- slot: "status",
- },
- },
- ];
- });
- 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: "title",
- title: "基础信息",
- },
- {
- type: "select",
- prop: "customerId",
- label: "客户名称",
- isLoad: {
- url: "/customer/page",
- req: {
- pageNum: 1,
- pageSize: 9999,
- },
- labelKey: "name",
- labelVal: "id",
- method: "post",
- resUrl: "rows",
- },
- itemWidth: 30,
- },
- {
- type: "input",
- prop: "code",
- label: "订单编号",
- itemWidth: 20,
- },
- {
- type: "slot",
- prop: "distributionCenter",
- label: "配送中心",
- slotName: "distributionCenter",
- },
- {
- type: "input",
- prop: "contactPerson",
- label: "收货信息",
- itemWidth: 20,
- placeholder: "收货负责人",
- },
- {
- type: "input",
- prop: "contactNumber",
- label: " ",
- itemWidth: 80,
- placeholder: "收货电话",
- style: {
- width: "30%",
- },
- },
- {
- 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("/jdOrder/page", sourceList.value.pagination).then((message) => {
- console.log(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 = {
- jdOrderDetailsList: [],
- countryId: "44",
- };
- getCityData(formData.data.countryId, "20");
- };
- const submitForm = () => {
- console.log(byform.value);
- byform.value.handleSubmit((valid) => {
- const list = formData.data.jdOrderDetailsList;
- 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("/jdOrder/" + 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,
- }));
- });
- };
- 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.jdOrderDetailsList.length; i++) {
- const e = formData.data.jdOrderDetailsList[i];
- e.total = (e.price * 1000000 * e.quantity) / 1000000;
- sum += e.total;
- }
- formData.data.amountMoney = sum;
- };
- const handleSelect = (row) => {
- const flag = formData.data.jdOrderDetailsList.some(
- (x) => x.productId === row.id
- );
- if (flag)
- return ElMessage({
- message: "该物品已选择",
- type: "info",
- });
- formData.data.jdOrderDetailsList.push({
- productName: row.name,
- productCode: row.code,
- productId: row.id,
- total: "",
- quantity: null,
- price: null,
- remark: "",
- });
- return ElMessage({
- message: "选择成功",
- type: "success",
- });
- };
- const handleRemove = (index) => {
- formData.data.jdOrderDetailsList.splice(index, 1);
- totalAmount();
- return ElMessage({
- message: "删除成功",
- type: "success",
- });
- };
- const handleClickCode = (row) => {
- formData.orderData = row;
- openDetails.value = true;
- };
- const openExcelDialog = ref(false);
- const openExcel = () => {
- importData.customerId = "";
- openExcelDialog.value = true;
- };
- const handleProgress = () => {
- excelLoading.value = true;
- };
- const handleError = (err) => {
- ElMessage({
- message: `${err},请重试!`,
- type: "info",
- });
- openExcelDialog.value = false;
- excelLoading.value = false;
- };
- const handleSuccess = (res) => {
- if (res.code != 200) {
- return ElMessage({
- message: `${res.msg},请重试!`,
- type: "info",
- });
- } else {
- ElMessage({
- message: "导入成功!",
- type: "success",
- });
- openExcelDialog.value = false;
- excelLoading.value = false;
- getList();
- }
- };
- const createFilter = (queryString) => {
- return (restaurant) => {
- return (
- restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0
- );
- };
- };
- const distributionCenterData = ref([]);
- const querySearchPerson = (queryString, callback) => {
- const results = queryString
- ? distributionCenterData.value.filter(createFilter(queryString))
- : distributionCenterData.value;
- callback(results);
- };
- const handlePerson = (item) => {
- formData.data.buyContactNumber = item.phone;
- };
- const getDistributionCenter = () => {
- proxy.post("/jdOrder/getDistributionCenter").then(
- (res) => {
- distributionCenterData.value = res.map((x) => ({
- label: x,
- value: x,
- }));
- },
- (err) => {
- console.log(err);
- }
- );
- proxy.post("/customer/page", { pageNum: 1, pageSize: 9999 }).then(
- (res) => {
- warehouseList.value = res.rows;
- },
- (err) => {
- console.log(err);
- }
- );
- };
- getDistributionCenter();
- 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("/jdOrder/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;
- };
- </script>
-
- <style lang="scss" scoped>
- .tenant {
- padding: 20px;
- }
- </style>
|