1
This commit is contained in:
53
src/api/jarvis/productJdConfig.js
Normal file
53
src/api/jarvis/productJdConfig.js
Normal file
@@ -0,0 +1,53 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询产品京东配置列表
|
||||
export function listProductJdConfig(query) {
|
||||
return request({
|
||||
url: '/jarvis/productJdConfig/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询产品京东配置详细
|
||||
export function getProductJdConfig(productModel) {
|
||||
return request({
|
||||
url: '/jarvis/productJdConfig/' + productModel,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增产品京东配置
|
||||
export function addProductJdConfig(data) {
|
||||
return request({
|
||||
url: '/jarvis/productJdConfig',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改产品京东配置
|
||||
export function updateProductJdConfig(data) {
|
||||
return request({
|
||||
url: '/jarvis/productJdConfig',
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除产品京东配置
|
||||
export function delProductJdConfig(productModels) {
|
||||
return request({
|
||||
url: '/jarvis/productJdConfig/' + productModels,
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 初始化默认数据
|
||||
export function initDefaultData() {
|
||||
return request({
|
||||
url: '/jarvis/productJdConfig/initData',
|
||||
method: 'post'
|
||||
})
|
||||
}
|
||||
|
||||
266
src/views/jarvis/productJdConfig/index.vue
Normal file
266
src/views/jarvis/productJdConfig/index.vue
Normal file
@@ -0,0 +1,266 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
|
||||
<el-form-item label="产品型号" prop="productModel">
|
||||
<el-input
|
||||
v-model="queryParams.productModel"
|
||||
placeholder="请输入产品型号"
|
||||
clearable
|
||||
@keyup.enter.native="handleQuery"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
v-hasPermi="['jarvis:productJdConfig:add']"
|
||||
>新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="success"
|
||||
plain
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
v-hasPermi="['jarvis:productJdConfig:edit']"
|
||||
>修改</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
v-hasPermi="['jarvis:productJdConfig:remove']"
|
||||
>删除</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="warning"
|
||||
plain
|
||||
icon="el-icon-download"
|
||||
size="mini"
|
||||
@click="handleInitData"
|
||||
v-hasPermi="['jarvis:productJdConfig:init']"
|
||||
>初始化数据</el-button>
|
||||
</el-col>
|
||||
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
||||
</el-row>
|
||||
|
||||
<el-table v-loading="loading" :data="productJdConfigList" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="产品型号" align="center" prop="productModel" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="京东链接" align="center" prop="jdUrl" :show-overflow-tooltip="true">
|
||||
<template slot-scope="scope">
|
||||
<el-link :href="scope.row.jdUrl" target="_blank" type="primary">{{ scope.row.jdUrl }}</el-link>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="佣金" align="center" prop="commission" width="120">
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.commission ? '¥' + scope.row.commission : '-' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
v-hasPermi="['jarvis:productJdConfig:edit']"
|
||||
>修改</el-button>
|
||||
<el-button
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
v-hasPermi="['jarvis:productJdConfig:remove']"
|
||||
>删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 添加或修改产品京东配置对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form-item label="产品型号" prop="productModel">
|
||||
<el-input v-model="form.productModel" placeholder="请输入产品型号" :disabled="form.productModel && !isAdd" />
|
||||
</el-form-item>
|
||||
<el-form-item label="京东链接" prop="jdUrl">
|
||||
<el-input v-model="form.jdUrl" type="textarea" :rows="3" placeholder="请输入京东链接" />
|
||||
</el-form-item>
|
||||
<el-form-item label="佣金" prop="commission">
|
||||
<el-input-number v-model="form.commission" :precision="2" :step="0.1" :min="0" placeholder="请输入佣金" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listProductJdConfig, getProductJdConfig, delProductJdConfig, addProductJdConfig, updateProductJdConfig, initDefaultData } from "@/api/jarvis/productJdConfig";
|
||||
|
||||
export default {
|
||||
name: "ProductJdConfig",
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 显示搜索条件
|
||||
showSearch: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 产品京东配置表格数据
|
||||
productJdConfigList: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否为新增
|
||||
isAdd: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
productModel: null,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {
|
||||
productModel: [
|
||||
{ required: true, message: "产品型号不能为空", trigger: "blur" }
|
||||
],
|
||||
jdUrl: [
|
||||
{ required: true, message: "京东链接不能为空", trigger: "blur" }
|
||||
],
|
||||
commission: [
|
||||
{ required: true, message: "佣金不能为空", trigger: "blur" }
|
||||
]
|
||||
}
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询产品京东配置列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listProductJdConfig(this.queryParams).then(response => {
|
||||
this.productJdConfigList = response.data || [];
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
productModel: null,
|
||||
jdUrl: null,
|
||||
commission: 0
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map(item => item.productModel);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.isAdd = true;
|
||||
this.open = true;
|
||||
this.title = "添加产品京东配置";
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
this.isAdd = false;
|
||||
const productModel = row.productModel || this.ids[0];
|
||||
getProductJdConfig(productModel).then(response => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改产品京东配置";
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm() {
|
||||
this.$refs["form"].validate(valid => {
|
||||
if (valid) {
|
||||
if (this.isAdd) {
|
||||
addProductJdConfig(this.form).then(response => {
|
||||
this.$modal.msgSuccess("新增成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
} else {
|
||||
updateProductJdConfig(this.form).then(response => {
|
||||
this.$modal.msgSuccess("修改成功");
|
||||
this.open = false;
|
||||
this.getList();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const productModels = row.productModel ? [row.productModel] : this.ids;
|
||||
this.$modal.confirm('是否确认删除产品型号为"' + productModels + '"的数据项?').then(() => {
|
||||
return delProductJdConfig(productModels.join(','));
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
},
|
||||
/** 初始化数据按钮操作 */
|
||||
handleInitData() {
|
||||
this.$modal.confirm('是否确认初始化默认产品数据?').then(() => {
|
||||
return initDefaultData();
|
||||
}).then(() => {
|
||||
this.getList();
|
||||
this.$modal.msgSuccess("初始化成功");
|
||||
}).catch(() => {});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user