|
|
@@ -12,11 +12,53 @@
|
|
|
></el-input>
|
|
|
<div class="seach-btn" @click="getCargoList">查询</div>
|
|
|
</div>
|
|
|
- <el-button v-auth="'ADDCARGO'" type="primary" @click="addCargo">
|
|
|
+ <el-button v-auth="'ADDCARGO'" type="primary" @click="visable = true">
|
|
|
添加货种
|
|
|
</el-button>
|
|
|
</div>
|
|
|
-
|
|
|
+ <el-dialog
|
|
|
+ v-model="visable"
|
|
|
+ :title="currentCargoId ? '修改货种' : '添加货种'"
|
|
|
+ width="550px"
|
|
|
+ @close="resetForm()"
|
|
|
+ >
|
|
|
+ <template v-slot:default>
|
|
|
+ <div class="df jcc">
|
|
|
+ <el-form
|
|
|
+ :model="ruleForm"
|
|
|
+ :rules="rules"
|
|
|
+ ref="form"
|
|
|
+ label-width="110px"
|
|
|
+ label-position="left"
|
|
|
+ >
|
|
|
+ <el-form-item prop="cargo" label="货种名称">
|
|
|
+ <el-input
|
|
|
+ style="width: 200px"
|
|
|
+ v-model="ruleForm.cargo"
|
|
|
+ placeholder="请填写货种名称"
|
|
|
+ ></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="proxyIds" label="启用代理">
|
|
|
+ <RemoteSelect
|
|
|
+ api="getAgencySelect"
|
|
|
+ v-model="ruleForm.proxyIds"
|
|
|
+ multiple
|
|
|
+ @selectItem="selectAgency($event)"
|
|
|
+ class="mb10"
|
|
|
+ ></RemoteSelect>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-slot:footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button @click="resetForm">取 消</el-button>
|
|
|
+ <el-button type="primary" @click="addCargo(ruleForm)">
|
|
|
+ 确 定
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
<div style="margin-top: 24px">
|
|
|
<el-table :data="tableData" stripe style="width: 100%">
|
|
|
<el-table-column
|
|
|
@@ -41,8 +83,21 @@
|
|
|
{{ subTimeStr(scope.row.createTime) }}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="启用/禁用" min-width="80" align="center">
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-switch v-model="scope.disabled"></el-switch>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="操作" min-width="80" align="center">
|
|
|
- <el-button disabled size="small" type="danger">删除</el-button>
|
|
|
+ <template v-slot="scope">
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ @click="showUpdate(scope.row)"
|
|
|
+ type="primary"
|
|
|
+ >
|
|
|
+ 修改
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<div style="width: 100%; text-align: right; margin-top: 43px">
|
|
|
@@ -68,7 +123,36 @@ let currentPage = ref(1);
|
|
|
let total = ref(0);
|
|
|
let term = ref("");
|
|
|
let loginAccountId = ref(0);
|
|
|
-let cargo = ref("");
|
|
|
+let currentCargoId = ref(0);
|
|
|
+let form = ref(null);
|
|
|
+let visable = ref(false);
|
|
|
+let ruleForm = ref({
|
|
|
+ cargo: "",
|
|
|
+ proxyIds: "",
|
|
|
+});
|
|
|
+function resetForm() {
|
|
|
+ visable.value = false;
|
|
|
+ form.value.resetFields();
|
|
|
+}
|
|
|
+const rules = ref({
|
|
|
+ cargo: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请填写货种",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ proxyIds: [
|
|
|
+ {
|
|
|
+ required: true,
|
|
|
+ message: "请选择代理",
|
|
|
+ trigger: "blur",
|
|
|
+ },
|
|
|
+ ],
|
|
|
+});
|
|
|
+function selectAgency(e) {
|
|
|
+ console.log(e);
|
|
|
+}
|
|
|
|
|
|
async function getCargoList() {
|
|
|
let res = await api.getCargoList({
|
|
|
@@ -90,40 +174,55 @@ function pageChange(e) {
|
|
|
currentPage.value = e;
|
|
|
getCargoList();
|
|
|
}
|
|
|
-function addCargo() {
|
|
|
- ElMessageBox.prompt("请输入货种名称", "添加货种", {
|
|
|
- confirmButtonText: "添加",
|
|
|
- cancelButtonText: "取消",
|
|
|
- inputPattern: /^[\s\S]*.*[^\s][\s\S]*$/,
|
|
|
- inputErrorMessage: "请输入货种名称",
|
|
|
- })
|
|
|
- .then(async ({ value }) => {
|
|
|
- let res = await api.addCargo({
|
|
|
- loginAccountId: loginAccountId.value,
|
|
|
- cargo: value,
|
|
|
- });
|
|
|
- if (res.data.status == 0) {
|
|
|
- ElNotification({
|
|
|
- title: "成功",
|
|
|
- duration: 1500,
|
|
|
- message: res.data.msg,
|
|
|
- type: "success",
|
|
|
- });
|
|
|
- getCargoList();
|
|
|
- } else {
|
|
|
- ElNotification({
|
|
|
- title: "失败",
|
|
|
- duration: 1500,
|
|
|
- message: res.data.msg,
|
|
|
- type: "error",
|
|
|
- });
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(() => {});
|
|
|
+async function addCargo() {
|
|
|
+ console.log(ruleForm.value);
|
|
|
+ let { cargo, proxyIds } = ruleForm.value;
|
|
|
+ let arr = [];
|
|
|
+ for (let i of proxyIds) {
|
|
|
+ arr.push(i.value);
|
|
|
+ }
|
|
|
+ let res = await api.addCargo({
|
|
|
+ cargo,
|
|
|
+ proxyIds: arr.join(","),
|
|
|
+ });
|
|
|
+ if (res.data.status == 0) {
|
|
|
+ ElNotification({
|
|
|
+ title: "成功",
|
|
|
+ duration: 1500,
|
|
|
+ message: res.data.msg,
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ resetForm();
|
|
|
+ getCargoList();
|
|
|
+ } else {
|
|
|
+ ElNotification({
|
|
|
+ title: "失败",
|
|
|
+ duration: 1500,
|
|
|
+ message: res.data.msg,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
-function closeModal() {
|
|
|
- cargo.value = "";
|
|
|
+async function showUpdate(item) {
|
|
|
+ console.log(item);
|
|
|
+ visable.value = true;
|
|
|
+ let { id: cargoId } = item;
|
|
|
+ currentCargoId.value = cargoId;
|
|
|
+ ruleForm.value = {
|
|
|
+ proxyIds: [],
|
|
|
+ };
|
|
|
+ let res = await api.getAgencySelected({
|
|
|
+ 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(() => {
|