Closed xhlsmile closed 9 months ago
是弹窗使用,还是新页面使用
是弹窗使用,还是新页面使用
新页面使用
formOption: { tagId: 'product_index', tagName: "商品", viewType: 'tag', layout: [ ] },
是弹窗使用,还是新页面使用
新页面使用
formOption: { tagId: 'product_index', tagName: "商品", viewType: 'tag', layout: [ ] },
我测试了是没有问题的
<template>
<div class="ma-content-block lg:flex justify-between p-4">
<!-- CRUD 组件 -->
<ma-crud :options="options" :columns="columns" ref="crudRef">
</ma-crud>
</div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import appProduct from '@/api/test/index'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'
const crudRef = ref()
const options = reactive({
id: 'app_product',
rowSelection: {
showCheckedAll: true
},
pk: 'id',
operationColumn: true,
operationColumnWidth: 160,
// formOption: {
// viewType: 'modal',
// width: 600
// },
formOption: { tagId: 'product_index', tagName: "商品", viewType: 'tag', layout: [ ] },
api: appProduct.getList,
add: {
show: true,
api: appProduct.save,
auth: ['recharge:appProduct:save']
},
edit: {
show: true,
api: appProduct.update,
auth: ['recharge:appProduct:update']
},
delete: {
show: true,
api: appProduct.deletes,
auth: ['recharge:appProduct:delete']
}
})
const columns = reactive([
{
title: "ID",
dataIndex: "id",
formType: "input",
addDisplay: false,
editDisplay: false,
hide: true,
commonRules: {
required: true,
message: "请输入ID"
}
},
{
title: "SKU",
dataIndex: "sku",
formType: "sku",
search: true
},
{
title: "",
dataIndex: "created_at",
formType: "date",
addDisplay: false,
editDisplay: false,
hide: true,
showTime: true
},
{
title: "",
dataIndex: "updated_at",
formType: "date",
addDisplay: false,
editDisplay: false,
hide: true,
showTime: true
}
])
</script>
<script> export default { name: 'recharge:appProduct' } </script>
<?php
namespace App\Recharge\Controller\Admin;
use App\Recharge\Service\AppProductService;
use App\Recharge\Request\AppProductRequest;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\DeleteMapping;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\HttpServer\Annotation\PutMapping;
use Mine\Annotation\Auth;
use Mine\Annotation\RemoteState;
use Mine\Annotation\OperationLog;
use Mine\Annotation\Permission;
use Mine\MineController;
use Psr\Http\Message\ResponseInterface;
/**
* 测试控制器
* Class AppProductController
*/
#[Controller(prefix: "recharge/appProduct"), Auth]
class AppProductController extends MineController
{
/**
* 业务处理服务
* AppProductService
*/
#[Inject]
protected AppProductService $service;
/**
* 列表
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[GetMapping("index"), Permission("recharge:appProduct, recharge:appProduct:index")]
public function index(): ResponseInterface
{
return $this->success($this->service->getPageList($this->request->all()));
}
/**
* 新增
* @param AppProductRequest $request
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[PostMapping("save"), Permission("recharge:appProduct:save"), OperationLog]
public function save(AppProductRequest $request): ResponseInterface
{
return $this->success(['id' => $this->service->save($request->all())]);
}
/**
* 更新
* @param int $id
* @param AppProductRequest $request
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[PutMapping("update/{id}"), Permission("recharge:appProduct:update"), OperationLog]
public function update(int $id, AppProductRequest $request): ResponseInterface
{
return $this->service->update($id, $request->all()) ? $this->success() : $this->error();
}
/**
* 读取数据
* @param int $id
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[GetMapping("read/{id}"), Permission("recharge:appProduct:read")]
public function read(int $id): ResponseInterface
{
return $this->success($this->service->read($id));
}
/**
* 单个或批量删除数据到回收站
* @return ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[DeleteMapping("delete"), Permission("recharge:appProduct:delete"), OperationLog]
public function delete(): ResponseInterface
{
return $this->service->delete((array) $this->request->input('ids', [])) ? $this->success() : $this->error();
}
/**
* 远程万能通用列表接口
* @return ResponseInterface
*/
#[PostMapping("remote"), RemoteState(true)]
public function remote(): ResponseInterface
{
return $this->success($this->service->getRemoteList($this->request->all()));
}
}
<?php
namespace App\Recharge\Model;
use Mine\MineModel;
class AppProduct extends MineModel
{
/**
* The table associated with the model.
*
* @var string|null
*/
protected ?string $table = 'app_product';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected array $fillable = [
'id', 'sku', 'created_at', 'updated_at'
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected array $casts = [
'sku' => 'array'
];
}
好了, 我的错, 我才发现编辑详情取的是列表的数据 而我的列表数据是不对的, 抱歉(。・_・。)ノI’m sorry~
@taobali32 我发现个问题, 我删除规格属性的时候, 我编辑的价格库存等数据就变的不对应啦
我编辑的价格库存等数据就变的不
每一次都会变得,没错的, 因为要组合sku, 你想要的那种可以自己实现. 保留老数据, 获得新改动的数据后, 2者对比 然后合并数据实现