mirror of
https://gitee.com/hzchunfen/erp.git
synced 2025-11-30 22:20:45 +00:00
feat: #10000 店铺增加成本倍率
This commit is contained in:
parent
65c6aebf46
commit
21cd070e92
@ -40,6 +40,7 @@ class ShopsController extends Controller
|
||||
$validator = Validator::make($request->all(), [
|
||||
'name' => 'required|string|max:191|unique:shops,name',
|
||||
'plat_id' => 'required|integer',
|
||||
'ratio' => 'required|numeric',
|
||||
]);
|
||||
if ($validator->fails()) {
|
||||
$this->setValidatorFailResponse($validator->getMessageBag()->getMessages());
|
||||
@ -49,6 +50,7 @@ class ShopsController extends Controller
|
||||
$shop = new Shop();
|
||||
$shop->name = $request->name;
|
||||
$shop->plat_id = $request->plat_id;
|
||||
$shop->ratio = $request->ratio;
|
||||
if (0 == $request->plat_id) {
|
||||
$shop->status = 2;
|
||||
}
|
||||
@ -57,6 +59,15 @@ class ShopsController extends Controller
|
||||
return response($this->res, $this->res['httpCode']);
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$shop = Shop::query()->find($id);
|
||||
$shop->ratio = $request->ratio;
|
||||
$shop->save();
|
||||
|
||||
return response($this->res, $this->res['httpCode']);
|
||||
}
|
||||
|
||||
public function authBind(Request $request)
|
||||
{
|
||||
[$shopId, $platId] = explode('_', $request->get('state'));
|
||||
|
||||
@ -29,6 +29,7 @@ class CreateShopsTable extends Migration
|
||||
$table->text('scope')->nullable()->comment('接口列表');
|
||||
$table->text('pop_auth_token_create_response')->nullable()->comment('授权认证信息');
|
||||
$table->unsignedTinyInteger('status')->index()->default(0)->comment('状态');
|
||||
$table->decimal('ratio')->default(1)->comment('成本倍率');
|
||||
$table->softDeletes();
|
||||
$table->timestamps();
|
||||
//索引
|
||||
|
||||
8
resources/frontend/src/api/shop.js
vendored
8
resources/frontend/src/api/shop.js
vendored
@ -33,3 +33,11 @@ export function downloadGoods(id) {
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
|
||||
export function updateStore(id, params) {
|
||||
return http({
|
||||
url: `/api/shops/${id}`,
|
||||
method: "patch",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
||||
@ -5,10 +5,16 @@
|
||||
|
||||
<div class="table" style="margin-top: 10px">
|
||||
<el-table v-loading="loading" :data="tableData" style="width: 100%">
|
||||
<el-table-column prop="id" label="ID" width="180"> </el-table-column>
|
||||
<el-table-column prop="name" label="店铺名称" width="180">
|
||||
<el-table-column prop="id" label="ID"> </el-table-column>
|
||||
<el-table-column prop="name" label="店铺名称">
|
||||
</el-table-column>
|
||||
<el-table-column prop="plat_id" label="所属平台"></el-table-column>
|
||||
<el-table-column label="成本倍率">
|
||||
<template slot-scope="scope">
|
||||
<el-input v-model="scope.row.ratio" placeholder="成本倍率" @change="handleCellChange(scope.row)">
|
||||
</el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作">
|
||||
<template slot-scope="scope">
|
||||
<el-button type="danger" v-if="scope.row.status === '未授权'"><a :href="scope.row.authUrl"
|
||||
@ -47,17 +53,20 @@
|
||||
</div>
|
||||
|
||||
<!-- 新增店铺 -->
|
||||
<el-dialog title="新增店铺" :visible.sync="dialogFormVisible" :close-on-click-modal="false">
|
||||
<el-form :model="form">
|
||||
<el-dialog title="新增店铺" :visible.sync="dialogFormVisible" :close-on-click-modal="false" width="20%">
|
||||
<el-form ref="form" :rules="rules" :model="form" lable-width="80px">
|
||||
<el-form-item label="店铺名称">
|
||||
<el-input v-model="form.name" placeholder="输入店铺名称"></el-input>
|
||||
<el-input v-model="form.name" placeholder="输入店铺名称" style="width: 400px;"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="店铺平台">
|
||||
<el-select v-model="form.plat_id" placeholder="输入店铺平台">
|
||||
<el-select v-model="form.plat_id" placeholder="输入店铺平台" style="width: 400px;">
|
||||
<el-option v-for="(item, index) in storeId" :key="index" :label="item" :value="index">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="成本倍率">
|
||||
<el-input v-model="form.ratio" placeholder="成本倍率" style="width: 400px;"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="dialogFormVisible = false">取 消</el-button>
|
||||
@ -68,7 +77,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { shopListId, shopAdd, storeList, downloadGoods } from "../../api/shop";
|
||||
import { shopListId, shopAdd, storeList, downloadGoods, updateStore } from "../../api/shop";
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
@ -76,6 +85,18 @@ export default {
|
||||
form: {
|
||||
name: "",
|
||||
plat_id: "",
|
||||
ratio: 1,
|
||||
},
|
||||
rules: {
|
||||
name: [
|
||||
{ required: true, message: '请输入店铺名称', trigger: 'blur' },
|
||||
],
|
||||
plat_id: [
|
||||
{ required: true, message: '请选择店铺平台', trigger: 'blur' },
|
||||
],
|
||||
ratio: [
|
||||
{ required: true, message: '请输入成本倍率', trigger: 'blur', },
|
||||
],
|
||||
},
|
||||
storeId: [], // 店铺id
|
||||
loading: true,
|
||||
@ -161,6 +182,20 @@ export default {
|
||||
});
|
||||
});
|
||||
},
|
||||
handleCellChange(row) {
|
||||
this.$confirm('确认修改成本倍率吗?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
}).then(() => {
|
||||
updateStore(row.id, { ratio: row.ratio }).then((res) => {
|
||||
this.$message({
|
||||
type: 'info',
|
||||
message: res.data.message
|
||||
})
|
||||
})
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user