|
@@ -18,7 +18,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
<el-dialog
|
|
<el-dialog
|
|
|
v-model="visable"
|
|
v-model="visable"
|
|
|
- :title="currentCargoId ? '修改货种' : '添加货种'"
|
|
|
|
|
|
|
+ :title="ruleForm.cargoId ? '修改货种' : '添加货种'"
|
|
|
width="550px"
|
|
width="550px"
|
|
|
@close="resetForm()"
|
|
@close="resetForm()"
|
|
|
>
|
|
>
|
|
@@ -41,7 +41,7 @@
|
|
|
<el-form-item prop="proxyIds" label="启用代理">
|
|
<el-form-item prop="proxyIds" label="启用代理">
|
|
|
<RemoteSelect
|
|
<RemoteSelect
|
|
|
api="getAgencySelect"
|
|
api="getAgencySelect"
|
|
|
- v-model="ruleForm.proxyIds"
|
|
|
|
|
|
|
+ :value="ruleForm.proxyIds"
|
|
|
multiple
|
|
multiple
|
|
|
@selectItem="selectAgency($event)"
|
|
@selectItem="selectAgency($event)"
|
|
|
class="mb10"
|
|
class="mb10"
|
|
@@ -85,7 +85,12 @@
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="启用/禁用" min-width="80" align="center">
|
|
<el-table-column label="启用/禁用" min-width="80" align="center">
|
|
|
<template v-slot="scope">
|
|
<template v-slot="scope">
|
|
|
- <el-switch v-model="scope.disabled"></el-switch>
|
|
|
|
|
|
|
+ <el-switch
|
|
|
|
|
+ v-model="scope.row.status"
|
|
|
|
|
+ :active-value="1"
|
|
|
|
|
+ :inactive-value="0"
|
|
|
|
|
+ @change="changeStatus($event, scope.row.id)"
|
|
|
|
|
+ ></el-switch>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" min-width="80" align="center">
|
|
<el-table-column label="操作" min-width="80" align="center">
|
|
@@ -115,7 +120,7 @@
|
|
|
<script setup>
|
|
<script setup>
|
|
|
import api from "../../apis/fetch";
|
|
import api from "../../apis/fetch";
|
|
|
import { ref, onMounted } from "vue";
|
|
import { ref, onMounted } from "vue";
|
|
|
-import { ElNotification, ElMessageBox } from "element-plus";
|
|
|
|
|
|
|
+import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
|
|
|
import { subTimeStr } from "../../utils/utils";
|
|
import { subTimeStr } from "../../utils/utils";
|
|
|
|
|
|
|
|
let tableData = ref([]);
|
|
let tableData = ref([]);
|
|
@@ -123,15 +128,15 @@ let currentPage = ref(1);
|
|
|
let total = ref(0);
|
|
let total = ref(0);
|
|
|
let term = ref("");
|
|
let term = ref("");
|
|
|
let loginAccountId = ref(0);
|
|
let loginAccountId = ref(0);
|
|
|
-let currentCargoId = ref(0);
|
|
|
|
|
let form = ref(null);
|
|
let form = ref(null);
|
|
|
let visable = ref(false);
|
|
let visable = ref(false);
|
|
|
let ruleForm = ref({
|
|
let ruleForm = ref({
|
|
|
cargo: "",
|
|
cargo: "",
|
|
|
- proxyIds: "",
|
|
|
|
|
|
|
+ proxyIds: [],
|
|
|
});
|
|
});
|
|
|
function resetForm() {
|
|
function resetForm() {
|
|
|
visable.value = false;
|
|
visable.value = false;
|
|
|
|
|
+ ruleForm.value = {};
|
|
|
form.value.resetFields();
|
|
form.value.resetFields();
|
|
|
}
|
|
}
|
|
|
const rules = ref({
|
|
const rules = ref({
|
|
@@ -151,7 +156,7 @@ const rules = ref({
|
|
|
],
|
|
],
|
|
|
});
|
|
});
|
|
|
function selectAgency(e) {
|
|
function selectAgency(e) {
|
|
|
- console.log(e);
|
|
|
|
|
|
|
+ ruleForm.value.proxyIds = e;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function getCargoList() {
|
|
async function getCargoList() {
|
|
@@ -175,13 +180,17 @@ function pageChange(e) {
|
|
|
getCargoList();
|
|
getCargoList();
|
|
|
}
|
|
}
|
|
|
async function addCargo() {
|
|
async function addCargo() {
|
|
|
- console.log(ruleForm.value);
|
|
|
|
|
- let { cargo, proxyIds } = ruleForm.value;
|
|
|
|
|
|
|
+ let { cargo, proxyIds, cargoId } = ruleForm.value;
|
|
|
let arr = [];
|
|
let arr = [];
|
|
|
for (let i of proxyIds) {
|
|
for (let i of proxyIds) {
|
|
|
- arr.push(i.value);
|
|
|
|
|
|
|
+ arr.push(i.key);
|
|
|
}
|
|
}
|
|
|
- let res = await api.addCargo({
|
|
|
|
|
|
|
+ let postData = {};
|
|
|
|
|
+ if (cargoId) {
|
|
|
|
|
+ postData = { cargoId };
|
|
|
|
|
+ }
|
|
|
|
|
+ let res = await api[cargoId ? "updateCargo" : "addCargo"]({
|
|
|
|
|
+ ...postData,
|
|
|
cargo,
|
|
cargo,
|
|
|
proxyIds: arr.join(","),
|
|
proxyIds: arr.join(","),
|
|
|
});
|
|
});
|
|
@@ -195,34 +204,33 @@ async function addCargo() {
|
|
|
resetForm();
|
|
resetForm();
|
|
|
getCargoList();
|
|
getCargoList();
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ console.log(res);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+async function changeStatus(status, cargoId) {
|
|
|
|
|
+ let res = await api.updateCargoStatus({
|
|
|
|
|
+ status,
|
|
|
|
|
+ cargoId,
|
|
|
|
|
+ });
|
|
|
|
|
+ if (res.data.status == 0) {
|
|
|
ElNotification({
|
|
ElNotification({
|
|
|
- title: "失败",
|
|
|
|
|
|
|
+ title: (status == 1 ? "启用" : "禁用") + "成功",
|
|
|
duration: 1500,
|
|
duration: 1500,
|
|
|
message: res.data.msg,
|
|
message: res.data.msg,
|
|
|
- type: "error",
|
|
|
|
|
|
|
+ type: "success",
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async function showUpdate(item) {
|
|
async function showUpdate(item) {
|
|
|
- console.log(item);
|
|
|
|
|
visable.value = true;
|
|
visable.value = true;
|
|
|
- let { id: cargoId } = item;
|
|
|
|
|
- currentCargoId.value = cargoId;
|
|
|
|
|
|
|
+ let { id: cargoId, proxyCargos: proxyIds, cargo } = item;
|
|
|
ruleForm.value = {
|
|
ruleForm.value = {
|
|
|
- proxyIds: [],
|
|
|
|
|
- };
|
|
|
|
|
- let res = await api.getAgencySelected({
|
|
|
|
|
|
|
+ proxyIds,
|
|
|
|
|
+ cargo,
|
|
|
cargoId,
|
|
cargoId,
|
|
|
- });
|
|
|
|
|
- ruleForm.value.proxyIds = [];
|
|
|
|
|
- for (let i of res.data.result) {
|
|
|
|
|
- ruleForm.value.proxyIds.push({
|
|
|
|
|
- value: i.proxyName,
|
|
|
|
|
- key: i.proxyId,
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- console.log(res);
|
|
|
|
|
|
|
+ };
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
onMounted(() => {
|