init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
525
public/assets/js/backend/shopro/goods/comment.js
Normal file
525
public/assets/js/backend/shopro/goods/comment.js
Normal file
@@ -0,0 +1,525 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const { ElMessageBox } = ElementPlus
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
order_id: new URLSearchParams(location.search).get('order_id'),
|
||||
order_item_id: new URLSearchParams(location.search).get('order_item_id'),
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
'goods.title': '',
|
||||
user: { field: 'user.nickname', value: '' },
|
||||
content: '',
|
||||
status: '',
|
||||
},
|
||||
tools: {
|
||||
'goods.title': {
|
||||
type: 'tinput',
|
||||
label: '商品名称',
|
||||
value: '',
|
||||
},
|
||||
user: {
|
||||
type: 'tinputprepend',
|
||||
label: '用户信息',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'user.nickname',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [
|
||||
{
|
||||
label: '用户昵称',
|
||||
value: 'user.nickname',
|
||||
},
|
||||
{
|
||||
label: '用户手机号',
|
||||
value: 'user.mobile',
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
content: {
|
||||
type: 'tinput',
|
||||
label: '评价内容',
|
||||
value: '',
|
||||
},
|
||||
status: {
|
||||
type: 'tselect',
|
||||
label: '状态',
|
||||
value: '',
|
||||
options: {
|
||||
data: [
|
||||
{
|
||||
label: '显示',
|
||||
value: 'normal',
|
||||
},
|
||||
{
|
||||
label: '隐藏',
|
||||
value: 'hidden',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
|
||||
if (state.order_id) {
|
||||
tempSearch = { ...tempSearch, order_id: state.order_id }
|
||||
}
|
||||
if (state.order_item_id) {
|
||||
tempSearch = { ...tempSearch, order_item_id: state.order_item_id }
|
||||
}
|
||||
|
||||
let search = composeFilter(tempSearch, {
|
||||
'goods.title': 'like',
|
||||
'user.nickname': 'like',
|
||||
'user.mobile': 'like',
|
||||
content: 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/comment',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const batchHandle = reactive({
|
||||
data: [],
|
||||
})
|
||||
function onChangeSelection(val) {
|
||||
batchHandle.data = val
|
||||
}
|
||||
function onBatchHandle(type) {
|
||||
let ids = []
|
||||
batchHandle.data.forEach((item) => {
|
||||
ids.push(item.id)
|
||||
})
|
||||
switch (type) {
|
||||
case 'delete':
|
||||
ElMessageBox.confirm('此操作将删除, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
onDelete(ids.join(','))
|
||||
});
|
||||
break;
|
||||
default:
|
||||
onCommand({ id: ids.join(','), type: type })
|
||||
break;
|
||||
}
|
||||
}
|
||||
function onCommand(item) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/edit/id/${item.id}`,
|
||||
type: 'POST',
|
||||
data: {
|
||||
status: item.type
|
||||
}
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenGoodsDetail(id) {
|
||||
Fast.api.open(`shopro/goods/goods/add?type=edit&id=${id}`, "商品详情", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
Fast.api.open("shopro/goods/comment/add?type=add", "添加虚拟评价", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/goods/comment/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onRecyclebin() {
|
||||
Fast.api.open('shopro/goods/comment/recyclebin', "回收站", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
onClipboard,
|
||||
state,
|
||||
getData,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
batchHandle,
|
||||
onChangeSelection,
|
||||
onBatchHandle,
|
||||
onCommand,
|
||||
onOpenGoodsDetail,
|
||||
onAdd,
|
||||
onEdit,
|
||||
onDelete,
|
||||
onRecyclebin
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
add: () => {
|
||||
Controller.form();
|
||||
},
|
||||
edit: () => {
|
||||
Controller.form();
|
||||
},
|
||||
form: () => {
|
||||
const { reactive, onMounted, getCurrentInstance } = Vue
|
||||
const addEdit = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
type: new URLSearchParams(location.search).get('type'),
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
fakeUserData: {},
|
||||
goodsData: {}
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
model: {
|
||||
content: '',
|
||||
images: [],
|
||||
level: 0,
|
||||
user_id: '',
|
||||
goods_id: '',
|
||||
status: 'normal',
|
||||
},
|
||||
rules: {
|
||||
content: [{ required: true, message: '请输入评价内容', trigger: 'blur' }],
|
||||
level: [{ required: true, message: '请选择评价星级', trigger: 'blur' }],
|
||||
user_id: [{ required: true, message: '请选择评价用户', trigger: 'blur' }],
|
||||
goods_id: [{ required: true, message: '请选择商品信息', trigger: 'blur' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
form.model = res.data
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onSelectFakeUser() {
|
||||
Fast.api.open("shopro/data/fake_user/select", "选择虚拟用户", {
|
||||
callback(data) {
|
||||
state.fakeUserData = data
|
||||
form.model.user_id = data.id
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDeleteFakeUser() {
|
||||
state.fakeUserData = {}
|
||||
form.model.user_id = ''
|
||||
}
|
||||
|
||||
function onSelectGoods() {
|
||||
Fast.api.open(`shopro/goods/goods/select`, "选择商品", {
|
||||
callback(data) {
|
||||
state.goodsData = data;
|
||||
form.model.goods_id = data.id;
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDeleteGoods() {
|
||||
state.goodsData = {};
|
||||
form.model.goods_id = '';
|
||||
}
|
||||
|
||||
function onChangeStatus() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/edit/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: {
|
||||
status: form.model.status
|
||||
}
|
||||
}, function (ret, res) {
|
||||
getDetail()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onReply() {
|
||||
Fast.api.open(`shopro/goods/comment/reply/id/${state.id}?id=${state.id}`, "回复", {
|
||||
callback() {
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/comment/add',
|
||||
type: 'POST',
|
||||
data: form.model,
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
state.type == 'edit' && getDetail()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
form,
|
||||
onSelectFakeUser,
|
||||
onDeleteFakeUser,
|
||||
onSelectGoods,
|
||||
onDeleteGoods,
|
||||
onChangeStatus,
|
||||
onReply,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addEdit', addEdit);
|
||||
},
|
||||
recyclebin: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const { ElMessageBox } = ElementPlus
|
||||
const recyclebin = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/comment/recyclebin',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeSort({ prop, order }) {
|
||||
state.order = order == 'ascending' ? 'asc' : 'desc';
|
||||
state.sort = prop;
|
||||
getData();
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const batchHandle = reactive({
|
||||
data: [],
|
||||
tools: [
|
||||
{
|
||||
type: 'restore',
|
||||
label: '还原',
|
||||
class: 'primary',
|
||||
},
|
||||
{
|
||||
type: 'destroy',
|
||||
label: '销毁',
|
||||
class: 'danger',
|
||||
},
|
||||
{
|
||||
type: 'all',
|
||||
label: '清空回收站',
|
||||
class: 'danger',
|
||||
},
|
||||
]
|
||||
})
|
||||
function onChangeSelection(val) {
|
||||
batchHandle.data = val
|
||||
}
|
||||
function onBatchHandle(type) {
|
||||
let ids = []
|
||||
batchHandle.data.forEach((item) => {
|
||||
ids.push(item.id)
|
||||
})
|
||||
switch (type) {
|
||||
case 'restore':
|
||||
onRestore(ids.join(','))
|
||||
break;
|
||||
case 'destroy':
|
||||
ElMessageBox.confirm('此操作将销毁, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
onDestroy(ids.join(','))
|
||||
});
|
||||
break;
|
||||
case 'all':
|
||||
ElMessageBox.confirm('此操作将清空回收站, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
onDestroy('all')
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onRestore(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/restore/id/${id}`,
|
||||
type: 'POST',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
function onDestroy(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/destroy/id/${id}`,
|
||||
type: 'POST',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
pagination,
|
||||
batchHandle,
|
||||
onChangeSelection,
|
||||
onBatchHandle,
|
||||
onRestore,
|
||||
onDestroy,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('recyclebin', recyclebin);
|
||||
},
|
||||
reply: () => {
|
||||
const { reactive, getCurrentInstance } = Vue
|
||||
const reply = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
model: {
|
||||
content: '',
|
||||
},
|
||||
rules: {
|
||||
content: [{ required: true, message: '请输入回复内容', trigger: 'change' }],
|
||||
},
|
||||
})
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/comment/reply/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: form.model,
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
form,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('reply', reply);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
1471
public/assets/js/backend/shopro/goods/goods.js
Normal file
1471
public/assets/js/backend/shopro/goods/goods.js
Normal file
File diff suppressed because it is too large
Load Diff
178
public/assets/js/backend/shopro/goods/service.js
Normal file
178
public/assets/js/backend/shopro/goods/service.js
Normal file
@@ -0,0 +1,178 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const { ElMessageBox } = ElementPlus
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/service',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeSort({ prop, order }) {
|
||||
state.order = order == 'ascending' ? 'asc' : 'desc';
|
||||
state.sort = prop;
|
||||
getData();
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const batchHandle = reactive({
|
||||
data: [],
|
||||
})
|
||||
function onChangeSelection(val) {
|
||||
batchHandle.data = val
|
||||
}
|
||||
function onBatchHandle(type) {
|
||||
let ids = []
|
||||
batchHandle.data.forEach((item) => {
|
||||
ids.push(item.id)
|
||||
})
|
||||
switch (type) {
|
||||
case 'delete':
|
||||
ElMessageBox.confirm('此操作将删除, 是否继续?', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
onDelete(ids.join(','))
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
Fast.api.open("shopro/goods/service/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/goods/service/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/service/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
pagination,
|
||||
batchHandle,
|
||||
onChangeSelection,
|
||||
onBatchHandle,
|
||||
onAdd,
|
||||
onEdit,
|
||||
onDelete
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
add: () => {
|
||||
Controller.form();
|
||||
},
|
||||
edit: () => {
|
||||
Controller.form();
|
||||
},
|
||||
form: () => {
|
||||
const { reactive, onMounted, getCurrentInstance } = Vue
|
||||
const addEdit = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
type: new URLSearchParams(location.search).get('type'),
|
||||
id: new URLSearchParams(location.search).get('id')
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
model: {
|
||||
name: '',
|
||||
image: '',
|
||||
description: '',
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/service/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
form.model = res.data;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: state.type == 'add' ? 'shopro/goods/service/add' : `shopro/goods/service/edit/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: form.model,
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
state.type == 'edit' && getDetail()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
form,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addEdit', addEdit);
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
89
public/assets/js/backend/shopro/goods/stock_log.js
Normal file
89
public/assets/js/backend/shopro/goods/stock_log.js
Normal file
@@ -0,0 +1,89 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
'goods.title': '',
|
||||
},
|
||||
tools: {
|
||||
'goods.title': {
|
||||
type: 'tinput',
|
||||
label: '商品名称',
|
||||
placeholder: '请输入商品名称',
|
||||
value: '',
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'goods.title': 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/stock_log',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeSort({ prop, order }) {
|
||||
state.order = order == 'ascending' ? 'asc' : 'desc';
|
||||
state.sort = prop;
|
||||
getData();
|
||||
}
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
227
public/assets/js/backend/shopro/goods/stock_warning.js
Normal file
227
public/assets/js/backend/shopro/goods/stock_warning.js
Normal file
@@ -0,0 +1,227 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
stock_type: 'all',
|
||||
'goods.title': '',
|
||||
},
|
||||
tools: {
|
||||
'goods.title': {
|
||||
type: 'tinput',
|
||||
label: '商品名称',
|
||||
placeholder: '请输入商品名称',
|
||||
value: '',
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
},
|
||||
stockType: {
|
||||
all: { name: '全部' },
|
||||
over: { name: '已售罄', num: 0 },
|
||||
no_enough: { name: '预警中', num: 0 },
|
||||
}
|
||||
})
|
||||
|
||||
const type = reactive({
|
||||
data: {
|
||||
stock_type: {
|
||||
all: { name: '全部' },
|
||||
over: { name: '已售罄', num: 0 },
|
||||
no_enough: { name: '预警中', num: 0 },
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'goods.title': 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/stock_warning',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.rows.data
|
||||
pagination.total = res.data.rows.total
|
||||
type.data.stock_type.over.num = res.data.over_total;
|
||||
type.data.stock_type.no_enough.num = res.data.warning_total;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeSort({ prop, order }) {
|
||||
state.order = order == 'ascending' ? 'asc' : 'desc';
|
||||
state.sort = prop;
|
||||
getData();
|
||||
}
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
function onChangeTab() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
function onAddStock(item) {
|
||||
Fast.api.open(`shopro/goods/stock_warning/addStock?id=${item.id}&stock=${item.stock}`, "补货", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onRecyclebin() {
|
||||
Fast.api.open('shopro/goods/stock_warning/recyclebin', "历史记录", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
type,
|
||||
getData,
|
||||
onChangeSort,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
onChangeTab,
|
||||
pagination,
|
||||
onAddStock,
|
||||
onRecyclebin,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
addstock: () => {
|
||||
const { reactive, getCurrentInstance } = Vue
|
||||
const addStock = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
stock: new URLSearchParams(location.search).get('stock')
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
model: {
|
||||
stock: '',
|
||||
},
|
||||
rules: {
|
||||
stock: [{ required: true, message: '请输入补充库存', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/goods/stock_warning/addStock/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: form.model,
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
state,
|
||||
form,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addStock', addStock);
|
||||
},
|
||||
recyclebin: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const recyclebin = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/goods/stock_warning/recyclebin',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeSort({ prop, order }) {
|
||||
state.order = order == 'ascending' ? 'asc' : 'desc';
|
||||
state.sort = prop;
|
||||
getData();
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
pagination,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('recyclebin', recyclebin);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Reference in New Issue
Block a user