init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
296
public/assets/js/backend/shopro/data/area.js
Normal file
296
public/assets/js/backend/shopro/data/area.js
Normal file
@@ -0,0 +1,296 @@
|
||||
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: 'asc',
|
||||
sort: '',
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/area',
|
||||
type: 'GET',
|
||||
data: {
|
||||
order: state.order,
|
||||
sort: state.sort,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
Fast.api.open("shopro/data/area/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/data/area/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/area/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
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: {
|
||||
pid: 0,
|
||||
id: '',
|
||||
name: '',
|
||||
},
|
||||
rules: {
|
||||
id: [{ required: true, message: '请输入行政区ID', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/area/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
form.model = res.data;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
const area = reactive({
|
||||
select: []
|
||||
})
|
||||
function getAreaSelect() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/area/select',
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
area.select = res.data;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: state.type == 'add' ? 'shopro/data/area/add' : `shopro/data/area/edit/old_id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: form.model,
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getAreaSelect()
|
||||
state.type == 'edit' && getDetail()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
form,
|
||||
area,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addEdit', addEdit);
|
||||
},
|
||||
select: () => {
|
||||
const { reactive, computed, onMounted, getCurrentInstance, nextTick } = Vue
|
||||
const select = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
selected: JSON.parse(new URLSearchParams(location.search).get('selected')),
|
||||
data: [],
|
||||
ids: [],
|
||||
label: {},
|
||||
checkedAll: false,
|
||||
})
|
||||
|
||||
function getSelect() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/area/select',
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data
|
||||
state.checkedAll = state.selected.province.split(',').length == state.data.length;
|
||||
|
||||
nextTick(() => {
|
||||
proxy.$refs['treeRef']?.getCheckedNodes().forEach((data) => {
|
||||
if (state.ids.includes(data.id)) {
|
||||
if (!state.label[data.level]) {
|
||||
state.label[data.level] = {};
|
||||
}
|
||||
state.label[data.level][data.id] = data.name;
|
||||
}
|
||||
});
|
||||
});
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
const isIndeterminate = computed(() => (state.ids.length > 0 && !state.checkedAll ? true : false));
|
||||
|
||||
function onChange() {
|
||||
if (state.checkedAll) {
|
||||
nextTick(() => {
|
||||
state.ids = [];
|
||||
proxy.$refs['treeRef']?.setCheckedNodes(state.data, false);
|
||||
state.data.forEach((d) => {
|
||||
state.ids.push(d.id);
|
||||
if (!state.label[d.level]) {
|
||||
state.label[d.level] = {};
|
||||
}
|
||||
state.label[d.level][d.id] = d.name;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
proxy.$refs['treeRef']?.setCheckedKeys([], false);
|
||||
state.ids = [];
|
||||
state.label = {
|
||||
province: {},
|
||||
city: {},
|
||||
district: {},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function onChangeCheck(data, checked, indeterminate) {
|
||||
// 全选
|
||||
if (!state.checkedAll) {
|
||||
// 选中(把自己放进去)
|
||||
if (checked) {
|
||||
state.ids.push(data.id);
|
||||
if (!state.label[data.level]) {
|
||||
state.label[data.level] = {};
|
||||
}
|
||||
state.label[data.level][data.id] = data.name;
|
||||
}
|
||||
}
|
||||
|
||||
// 未选中(把自己删除)
|
||||
if (!checked) {
|
||||
if (state.ids.includes(data.id)) {
|
||||
state.ids.splice(state.ids.indexOf(data.id), 1);
|
||||
for (var key in state.label[data.level]) {
|
||||
if (Number(key) == Number(data.id)) {
|
||||
delete state.label[data.level][key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.label.province)
|
||||
state.checkedAll = Object.keys(state.label.province).length == state.data.length;
|
||||
}
|
||||
|
||||
function deleteId(arr) {
|
||||
arr.forEach(item => {
|
||||
if (state.ids.includes(item.id)) {
|
||||
state.ids.splice(state.ids.indexOf(item.id), 1);
|
||||
delete state.label[item.level][item.id];
|
||||
}
|
||||
if (item.children && item.children.length > 0) {
|
||||
deleteId(item.children)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
state.ids = [];
|
||||
state.label = {
|
||||
province: {},
|
||||
city: {},
|
||||
district: {},
|
||||
};
|
||||
proxy.$refs['treeRef']?.getCheckedNodes().forEach(item => {
|
||||
state.ids.push(item.id)
|
||||
if (!state.label[item.level]) {
|
||||
state.label[item.level] = {};
|
||||
}
|
||||
state.label[item.level][item.id] = item.name;
|
||||
})
|
||||
proxy.$refs['treeRef']?.getCheckedNodes().forEach(item => {
|
||||
if (item.children && item.children.length > 0) {
|
||||
deleteId(item.children)
|
||||
}
|
||||
})
|
||||
Fast.api.close(state.label)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
for (var level in state.selected) {
|
||||
if (state.selected[level]) {
|
||||
state.selected[level].split(',').forEach((id) => {
|
||||
state.ids.push(id);
|
||||
});
|
||||
}
|
||||
}
|
||||
getSelect()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
isIndeterminate,
|
||||
onChange,
|
||||
onChangeCheck,
|
||||
onConfirm,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('select', select);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
224
public/assets/js/backend/shopro/data/express.js
Normal file
224
public/assets/js/backend/shopro/data/express.js
Normal file
@@ -0,0 +1,224 @@
|
||||
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: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
keyword: { field: 'name', value: '' },
|
||||
},
|
||||
tools: {
|
||||
keyword: {
|
||||
type: 'tinputprepend',
|
||||
label: '查询内容',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'name',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '快递公司',
|
||||
value: 'name',
|
||||
},
|
||||
{
|
||||
label: '快递编码',
|
||||
value: 'code',
|
||||
}]
|
||||
}
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
name: 'like',
|
||||
code: 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/express',
|
||||
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,
|
||||
})
|
||||
|
||||
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/data/express/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/data/express/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/express/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
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: '',
|
||||
code: '',
|
||||
weigh: 0,
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入快递公司', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '请输入快递编码', trigger: 'blur' }],
|
||||
weigh: [{ required: true, message: '请输入权重', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/express/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/data/express/add' : `shopro/data/express/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;
|
||||
});
|
||||
359
public/assets/js/backend/shopro/data/fake_user.js
Normal file
359
public/assets/js/backend/shopro/data/fake_user.js
Normal file
@@ -0,0 +1,359 @@
|
||||
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: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
user: { field: 'id', value: '' },
|
||||
gender: 'all',
|
||||
},
|
||||
tools: {
|
||||
user: {
|
||||
type: 'tinputprepend',
|
||||
label: '用户信息',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '用户ID',
|
||||
value: 'id',
|
||||
},
|
||||
{
|
||||
label: '用户名',
|
||||
value: 'username',
|
||||
},
|
||||
{
|
||||
label: '用户昵称',
|
||||
value: 'nickname',
|
||||
},
|
||||
{
|
||||
label: '用户手机号',
|
||||
value: 'mobile',
|
||||
},
|
||||
{
|
||||
label: '邮箱',
|
||||
value: 'email',
|
||||
}],
|
||||
}
|
||||
},
|
||||
gender: {
|
||||
type: 'tselect',
|
||||
label: '用户性别',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
label: '全部',
|
||||
value: 'all',
|
||||
},
|
||||
{
|
||||
label: '女',
|
||||
value: '0',
|
||||
},
|
||||
{
|
||||
label: '男',
|
||||
value: '1',
|
||||
}]
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
username: 'like',
|
||||
nickname: 'like',
|
||||
mobile: 'like',
|
||||
email: 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/fake_user',
|
||||
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,
|
||||
})
|
||||
|
||||
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/data/fake_user/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/data/fake_user/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/fake_user/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onRandom() {
|
||||
Fast.api.open('shopro/data/fake_user/random', "自动生成", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
Fast,
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
batchHandle,
|
||||
onChangeSelection,
|
||||
onBatchHandle,
|
||||
onAdd,
|
||||
onEdit,
|
||||
onDelete,
|
||||
onRandom
|
||||
}
|
||||
}
|
||||
}
|
||||
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: {
|
||||
avatar: '',
|
||||
username: '',
|
||||
nickname: '',
|
||||
email: '',
|
||||
mobile: '',
|
||||
password: '',
|
||||
gender: 0,
|
||||
},
|
||||
rules: {
|
||||
avatar: [{ required: true, message: '请选择用户头像', trigger: 'blur' }],
|
||||
username: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
||||
nickname: [{ required: true, message: '请输入用户昵称', trigger: 'blur' }],
|
||||
email: [{ required: true, message: '请输入电子邮箱', trigger: 'blur' }],
|
||||
mobile: [{ required: true, message: '请输入手机号', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/fake_user/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
form.model = res.data;
|
||||
form.model.password = '';
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: state.type == 'add' ? 'shopro/data/fake_user/add' : `shopro/data/fake_user/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);
|
||||
},
|
||||
select: function () {
|
||||
const { reactive, onMounted } = Vue
|
||||
const select = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/fake_user/select',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
function onSelect(item) {
|
||||
Fast.api.close(item)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
pagination,
|
||||
onSelect
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('select', select);
|
||||
},
|
||||
random: () => {
|
||||
const { reactive, getCurrentInstance } = Vue
|
||||
const random = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const form = reactive({
|
||||
model: {
|
||||
num: 1,
|
||||
},
|
||||
rules: {
|
||||
num: [{ required: true, message: '请输入生成虚拟人数', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/fake_user/random',
|
||||
type: 'POST',
|
||||
data: JSON.parse(JSON.stringify(form.model))
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
form,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('random', random);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
220
public/assets/js/backend/shopro/data/faq.js
Normal file
220
public/assets/js/backend/shopro/data/faq.js
Normal file
@@ -0,0 +1,220 @@
|
||||
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: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
keyword: '',
|
||||
},
|
||||
tools: {
|
||||
keyword: {
|
||||
type: 'tinput',
|
||||
label: '查询内容',
|
||||
placeholder: '请输入查询内容',
|
||||
value: '',
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
keyword: 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/faq',
|
||||
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,
|
||||
})
|
||||
|
||||
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:
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/faq/edit/id/${ids.join(',')}`,
|
||||
type: 'POST',
|
||||
data: {
|
||||
status: type
|
||||
}
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
Fast.api.open("shopro/data/faq/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/data/faq/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/faq/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
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: {
|
||||
title: '',
|
||||
content: '',
|
||||
status: 'normal',
|
||||
},
|
||||
rules: {
|
||||
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '请输入内容', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/faq/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/data/faq/add' : `shopro/data/faq/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;
|
||||
});
|
||||
355
public/assets/js/backend/shopro/data/page.js
Normal file
355
public/assets/js/backend/shopro/data/page.js
Normal file
@@ -0,0 +1,355 @@
|
||||
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/data/page',
|
||||
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/data/page/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/data/page/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/page/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: '',
|
||||
path: '',
|
||||
group: '',
|
||||
},
|
||||
rules: {
|
||||
name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
||||
path: [{ required: true, message: '请输入路径', trigger: 'blur' }],
|
||||
group: [{ required: true, message: '请输入分组', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/page/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/data/page/add' : `shopro/data/page/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);
|
||||
},
|
||||
select: () => {
|
||||
const { ref, reactive, onMounted, getCurrentInstance, nextTick } = Vue
|
||||
const select = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
data: [],
|
||||
height: [],
|
||||
currentIndex: 0,
|
||||
selected: {},
|
||||
});
|
||||
|
||||
async function getSelect() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/page/select',
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data;
|
||||
nextTick(() => {
|
||||
getHeight();
|
||||
});
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeIndex(index) {
|
||||
proxy.$refs.rightScrollRef.setScrollTop(state.height[index]);
|
||||
state.currentIndex = index;
|
||||
}
|
||||
|
||||
function onRightScroll(e) {
|
||||
let index = state.height.findIndex((item) => {
|
||||
return item > e.scrollTop;
|
||||
});
|
||||
if (index > 0) {
|
||||
state.currentIndex = index - 1;
|
||||
} else if (index == -1) {
|
||||
state.currentIndex = state.height.length - 1;
|
||||
}
|
||||
}
|
||||
|
||||
function onSelect(link) {
|
||||
state.selected = { ...link };
|
||||
if (link.path == '/pages/index/page') {
|
||||
Fast.api.open('shopro/decorate/template/select', "选择自定义页面", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/goods/index') {
|
||||
Fast.api.open('shopro/goods/goods/select', "选择商品", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/index/category') {
|
||||
Fast.api.open('shopro/category/select?from=page-category', "选择分类", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.ids) ? '?id=' + data.ids : '');
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/goods/list') {
|
||||
Fast.api.open('shopro/category/select?from=page-goods', "选择分类", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.ids) ? '?categoryId=' + data.ids : '');
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/public/richtext') {
|
||||
Fast.api.open('shopro/data/richtext/select', "选择富文本", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
} else if (
|
||||
link.path == '/pages/activity/groupon/list' ||
|
||||
link.path == '/pages/activity/seckill/list'
|
||||
) {
|
||||
let activityType = {
|
||||
groupon: 'groupon,groupon_ladder',
|
||||
seckill: 'seckill',
|
||||
};
|
||||
Fast.api.open(`shopro/activity/activity/select?type=${activityType[link.path.split('/')[3]]}`, "选择活动", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/goods/groupon' || link.path == '/pages/goods/seckill') {
|
||||
let activityType = {
|
||||
groupon: 'groupon,groupon_ladder',
|
||||
seckill: 'seckill',
|
||||
};
|
||||
Fast.api.open(`shopro/activity/activity/select?type=${activityType[link.path.split('/').pop()]}`, "选择活动", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?activity_id=' + data.id : '');
|
||||
Fast.api.open(`shopro/goods/goods/select?goods_ids=${data.goods_ids}`, "选择商品", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '&id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/goods/score') {
|
||||
Fast.api.open(`shopro/app/score_shop/select`, "选择积分商品", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
} else if (link.path == '/pages/coupon/detail') {
|
||||
Fast.api.open(`shopro/coupon/select?status=normal`, "选择优惠券", {
|
||||
callback(data) {
|
||||
state.selected.path += (!isEmpty(data.id) ? '?id=' + data.id : '');
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const rightRef = {};
|
||||
function setRightRef(el, item, index) {
|
||||
rightRef[item.group + index] = el;
|
||||
}
|
||||
function getHeight() {
|
||||
state.height = [];
|
||||
for (let e in rightRef) {
|
||||
state.height.push(rightRef[e].offsetTop);
|
||||
}
|
||||
}
|
||||
|
||||
const platformUrl = ref({});
|
||||
function getPlatformUrl() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/config/getPlatformUrl',
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
platformUrl.value = res.data
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
async function onConfirm() {
|
||||
state.selected.fullPath = {
|
||||
url: `${platformUrl.value.url.endsWith('/')
|
||||
? platformUrl.value.url.substr(0, platformUrl.value.url.length - 1)
|
||||
: platformUrl.value.url
|
||||
}${state.selected.path}`,
|
||||
appid: platformUrl.value.appid,
|
||||
pagepath: state.selected.path
|
||||
? '/pages/index/index?page=' + encodeURIComponent(state.selected.path)
|
||||
: '/pages/index/index',
|
||||
};
|
||||
Fast.api.close(state.selected)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getSelect();
|
||||
getPlatformUrl();
|
||||
});
|
||||
|
||||
return {
|
||||
state,
|
||||
getSelect,
|
||||
onRightScroll,
|
||||
onChangeIndex,
|
||||
onSelect,
|
||||
rightRef,
|
||||
setRightRef,
|
||||
getHeight,
|
||||
platformUrl,
|
||||
getPlatformUrl,
|
||||
onConfirm,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('select', select);
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
291
public/assets/js/backend/shopro/data/richtext.js
Normal file
291
public/assets/js/backend/shopro/data/richtext.js
Normal file
@@ -0,0 +1,291 @@
|
||||
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: '',
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
keyword: '',
|
||||
},
|
||||
tools: {
|
||||
keyword: {
|
||||
type: 'tinput',
|
||||
label: '查询内容',
|
||||
placeholder: '请输入查询内容',
|
||||
value: '',
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
keyword: 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/richtext',
|
||||
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,
|
||||
})
|
||||
|
||||
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/data/richtext/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/data/richtext/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/richtext/delete/id/${id}`,
|
||||
type: 'DELETE',
|
||||
}, function (ret, res) {
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
batchHandle,
|
||||
onChangeSelection,
|
||||
onBatchHandle,
|
||||
onAdd,
|
||||
onEdit,
|
||||
onDelete
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
add: () => {
|
||||
Controller.form();
|
||||
},
|
||||
edit: () => {
|
||||
Controller.form();
|
||||
},
|
||||
form: () => {
|
||||
const { reactive, onMounted, getCurrentInstance, nextTick } = 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: {
|
||||
title: '',
|
||||
content: '',
|
||||
},
|
||||
rules: {
|
||||
title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '请输入内容', trigger: 'blur' }],
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/data/richtext/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
form.model = res.data;
|
||||
nextTick(() => {
|
||||
Controller.api.bindevent();
|
||||
$('#richtextContent').html(form.model.content)
|
||||
})
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
form.model.content = $("#richtextContent").val()
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: state.type == 'add' ? 'shopro/data/richtext/add' : `shopro/data/richtext/edit/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: form.model,
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (state.type == 'add') {
|
||||
nextTick(() => {
|
||||
Controller.api.bindevent();
|
||||
})
|
||||
} else if (state.type == 'edit') {
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
form,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addEdit', addEdit);
|
||||
},
|
||||
select: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const select = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
order: '',
|
||||
sort: '',
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/data/richtext/select',
|
||||
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,
|
||||
})
|
||||
|
||||
function onAdd() {
|
||||
Fast.api.open("shopro/data/richtext/add?type=add", "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onSelect(item) {
|
||||
Fast.api.close(item)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onChangeSort,
|
||||
pagination,
|
||||
onAdd,
|
||||
onSelect
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('select', select);
|
||||
},
|
||||
api: {
|
||||
bindevent: function () {
|
||||
Form.api.bindevent($("form[role=form]"));
|
||||
}
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Reference in New Issue
Block a user