Commit 4634fe1a authored by 刘小敏's avatar 刘小敏

管理后台商品列表增加3D试戴图字段

parent b58fdb78
...@@ -216,6 +216,32 @@ class Goods extends Common ...@@ -216,6 +216,32 @@ class Goods extends Common
} }
public function upload3d($id = null)
{
if (!$this->request->isAjax()) {
$goods = $this->model->where('id', $id)->find();
$image_3d = '';
if ($goods) {
$image_3d = $goods->image_3d;
}
$this->view->assign('image_3d', urlencode($image_3d));
$this->view->assign('id', $id);
$this->view->assign('site', ['version' => config('site.version') ?: time()]);
return $this->view->fetch('shopro/goods/upload3d');
}
$params = $this->request->only(['image_3d']);
$goods = $this->model->where('id', $id)->find();
if (!$goods) {
$this->error(__('No Results were found'));
}
$goods->save($params);
$this->success('更新成功', null, ['image_3d' => $params['image_3d']]);
}
public function addStock($id) public function addStock($id)
{ {
if (!$this->request->isAjax()) { if (!$this->request->isAjax()) {
......
...@@ -373,6 +373,11 @@ ...@@ -373,6 +373,11 @@
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="3D试戴图" min-width="120">
<template #default="scope">
<sa-uploader v-model="scope.row.image_3d" @select="onSelect3DImage(scope.row)" @delete="onDelete3DImage(scope.row)" type="image"></sa-uploader>
</template>
</el-table-column>
<el-table-column sortable="custom" prop="price" label="价格" min-width="150"> <el-table-column sortable="custom" prop="price" label="价格" min-width="150">
<template #default="scope"> <template #default="scope">
<div>{{ scope.row.price?.join('~') || 0 }}</div> <div>{{ scope.row.price?.join('~') || 0 }}</div>
......
...@@ -45,7 +45,7 @@ const SaUploader = { ...@@ -45,7 +45,7 @@ const SaUploader = {
</el-image> </el-image>
</div> </div>
</div>`, </div>`,
emit: ['update:modelValue', 'success'], emit: ['update:modelValue', 'success', 'select', 'delete'],
props: { props: {
modelValue: { modelValue: {
type: [Array, String], type: [Array, String],
...@@ -96,13 +96,18 @@ const SaUploader = { ...@@ -96,13 +96,18 @@ const SaUploader = {
data.url.split(',').forEach(item => { data.url.split(',').forEach(item => {
urlList.value.push(item) urlList.value.push(item)
}); });
emit('update:modelValue', props.multiple ? urlList.value : urlList.value.join(',')) const newValue = props.multiple ? urlList.value : urlList.value.join(',');
emit('update:modelValue', newValue);
emit('select', { url: newValue });
} }
}); });
} }
function onDeleteFile(index) { function onDeleteFile(index) {
urlList.value.splice(index, 1) const deletedUrl = urlList.value[index];
emit('update:modelValue', props.multiple ? urlList.value : urlList.value.join(',')) urlList.value.splice(index, 1);
const newValue = props.multiple ? urlList.value : urlList.value.join(',');
emit('update:modelValue', newValue);
emit('delete', { url: deletedUrl, list: newValue });
} }
......
...@@ -357,6 +357,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -357,6 +357,40 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
}, function (ret, res) { }) }, function (ret, res) { })
} }
function onSelect3DImage(row) {
if (!row.image_3d) {
return;
}
Fast.api.ajax({
url: 'shopro/goods/goods/upload3d?id=' + row.id,
type: 'POST',
data: { image_3d: row.image_3d },
loading: true
}, function(ret, res) {
ElMessage.success('3D试戴图更新成功');
}, function(ret, res) {
ElMessage.error(res.msg || '更新失败');
row.image_3d = '';
});
}
function onDelete3DImage(row) {
ElMessageBox.confirm(`确定要删除商品ID [ ${row.id} ] 的3D试戴图吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}).then(() => {
Fast.api.ajax({
url: `shopro/goods/goods/upload3d?id=${row.id}`,
type: 'POST',
data: { image_3d: '' }
}, function (ret, res) {
row.image_3d = '';
}, function (ret, res) { })
});
}
function onRecyclebin() { function onRecyclebin() {
Fast.api.open('shopro/goods/goods/recyclebin', "回收站", { Fast.api.open('shopro/goods/goods/recyclebin', "回收站", {
callback() { callback() {
...@@ -414,6 +448,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin ...@@ -414,6 +448,8 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
onChangeCategoryIds, onChangeCategoryIds,
onFold, onFold,
defaultExpandedKeys, defaultExpandedKeys,
onSelect3DImage,
onDelete3DImage,
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment