- 框架初始化
 - 安装插件
 - 修复PHP8.4报错
This commit is contained in:
2025-04-19 17:21:20 +08:00
commit c6a4e1f5f6
5306 changed files with 967782 additions and 0 deletions

View File

@@ -0,0 +1,290 @@
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: '' },
room_id: '',
},
tools: {
user: {
type: 'tinputprepend',
label: '查询内容',
placeholder: '请输入查询内容',
value: {
field: 'id',
value: '',
},
options: {
data: [{
label: 'ID',
value: 'id',
},
{
label: '名称',
value: 'name',
}],
}
},
room_id: {
type: 'tselect',
label: '客服分类',
value: '',
options: {
data: [],
props: {
label: 'name'
}
},
},
},
condition: {},
}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
state.filter.tools.room_id.options.data = res.data.default_rooms
return false
}, function (ret, res) { })
}
function getData() {
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
let search = composeFilter(tempSearch, {
name: 'like',
});
Fast.api.ajax({
url: 'shopro/chat/common_word',
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/chat/common_word/edit/id/${ids.join(',')}`,
type: 'POST',
data: {
status: type
}
}, function (ret, res) {
getData()
}, function (ret, res) { })
break;
}
}
function onAdd() {
Fast.api.open("shopro/chat/common_word/add?type=add", "添加", {
callback() {
getData()
}
})
}
function onEdit(id) {
Fast.api.open(`shopro/chat/common_word/edit?type=edit&id=${id}`, "编辑", {
callback() {
getData()
}
})
}
function onDelete(id) {
Fast.api.ajax({
url: `shopro/chat/common_word/delete/id/${id}`,
type: 'DELETE',
}, function (ret, res) {
getData()
}, function (ret, res) { })
}
onMounted(() => {
getChatConfig()
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: {
room_id: '',
name: '',
content: '',
status: 'normal',
weigh: 0,
},
rules: {
room_id: [{ required: true, message: '请选择客服分类', trigger: ['blur', 'change'] }],
name: [{ required: true, message: '请输入标题', trigger: ['blur', 'change'] }],
content: [{ required: true, message: '请输入问题内容', trigger: ['blur', 'change'] }],
},
})
function getDetail() {
Fast.api.ajax({
url: `shopro/chat/common_word/detail/id/${state.id}`,
type: 'GET',
}, function (ret, res) {
form.model = res.data;
nextTick(() => {
Controller.api.bindevent();
$('#commonWordContent').html(form.model.content)
})
return false
}, function (ret, res) { })
}
const chat = reactive({
config: {}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
chat.config = res.data
return false
}, function (ret, res) { })
}
function onConfirm() {
form.model.content = $("#commonWordContent").val();
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
Fast.api.ajax({
url: state.type == 'add' ? 'shopro/chat/common_word/add' : `shopro/chat/common_word/edit/id/${state.id}`,
type: 'POST',
data: form.model,
}, function (ret, res) {
Fast.api.close()
}, function (ret, res) { })
}
});
}
onMounted(() => {
getChatConfig()
if (state.type == 'add') {
nextTick(() => {
Controller.api.bindevent();
})
} else if (state.type == 'edit') {
getDetail()
}
})
return {
state,
form,
chat,
onConfirm
}
}
}
createApp('addEdit', addEdit);
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
},
};
return Controller;
});

View File

@@ -0,0 +1,288 @@
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: '' },
room_id: '',
},
tools: {
user: {
type: 'tinputprepend',
label: '查询内容',
placeholder: '请输入查询内容',
value: {
field: 'id',
value: '',
},
options: {
data: [{
label: 'ID',
value: 'id',
},
{
label: '客服名称',
value: 'name',
}],
}
},
room_id: {
type: 'tselect',
label: '客服分类',
value: '',
options: {
data: [],
props: {
label: 'name'
}
},
},
},
condition: {},
}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
state.filter.tools.room_id.options.data = res.data.default_rooms
return false
}, function (ret, res) { })
}
function getData() {
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
let search = composeFilter(tempSearch, {
name: 'like',
});
Fast.api.ajax({
url: 'shopro/chat/customer_service',
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/chat/customer_service/add?type=add", "添加", {
callback() {
getData()
}
})
}
function onEdit(id) {
Fast.api.open(`shopro/chat/customer_service/edit?type=edit&id=${id}`, "编辑", {
callback() {
getData()
}
})
}
function onDelete(id) {
Fast.api.ajax({
url: `shopro/chat/customer_service/delete/id/${id}`,
type: 'DELETE',
}, function (ret, res) {
getData()
}, function (ret, res) { })
}
onMounted(() => {
getChatConfig()
getData()
})
return {
Fast,
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: {
room_id: '',
auth: 'admin',
auth_id: '',
name: '',
avatar: '',
max_num: 0,
},
rules: {
room_id: [{ required: true, message: '请选择客服分类', trigger: ['blur', 'change'] }],
auth_id: [{ required: true, message: '请选择所属管理员', trigger: ['blur', 'change'] }],
name: [{ required: true, message: '请输入客服名称', trigger: ['blur', 'change'] }],
avatar: [{ required: true, message: '请选择客服头像', trigger: ['blur', 'change'] }],
},
})
function getDetail() {
Fast.api.ajax({
url: `shopro/chat/customer_service/detail/id/${state.id}`,
type: 'GET',
}, function (ret, res) {
form.model = res.data
form.model.auth = res.data.customer_service_user?.auth;
form.model.auth_id = res.data.customer_service_user?.auth_id;
getCustomerServiceSelect()
return false
}, function (ret, res) { })
}
const chat = reactive({
config: {}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
chat.config = res.data
return false
}, function (ret, res) { })
}
const customerService = reactive({
select: []
})
function getCustomerServiceSelect() {
Fast.api.ajax({
url: `shopro/chat/customer_service/select`,
type: 'GET',
data: {
id: state.id,
room_id: form.model.room_id,
},
}, function (ret, res) {
customerService.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/chat/customer_service/add' : `shopro/chat/customer_service/edit/id/${state.id}`,
type: 'POST',
data: form.model,
}, function (ret, res) {
Fast.api.close()
}, function (ret, res) { })
}
});
}
onMounted(() => {
getChatConfig()
state.type == 'edit' && getDetail()
})
return {
state,
form,
chat,
customerService,
getCustomerServiceSelect,
onConfirm
}
}
}
createApp('addEdit', addEdit);
}
};
return Controller;
});

View File

@@ -0,0 +1,290 @@
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: '' },
room_id: '',
},
tools: {
user: {
type: 'tinputprepend',
label: '查询内容',
placeholder: '请输入查询内容',
value: {
field: 'id',
value: '',
},
options: {
data: [{
label: 'ID',
value: 'id',
},
{
label: '标题',
value: 'title',
}],
}
},
room_id: {
type: 'tselect',
label: '客服分类',
value: '',
options: {
data: [],
props: {
label: 'name'
}
},
},
},
condition: {},
}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
state.filter.tools.room_id.options.data = res.data.default_rooms
return false
}, function (ret, res) { })
}
function getData() {
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
let search = composeFilter(tempSearch, {
title: 'like',
});
Fast.api.ajax({
url: 'shopro/chat/question',
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/chat/question/edit/id/${ids.join(',')}`,
type: 'POST',
data: {
status: type
}
}, function (ret, res) {
getData()
}, function (ret, res) { })
break;
}
}
function onAdd() {
Fast.api.open("shopro/chat/question/add?type=add", "添加", {
callback() {
getData()
}
})
}
function onEdit(id) {
Fast.api.open(`shopro/chat/question/edit?type=edit&id=${id}`, "编辑", {
callback() {
getData()
}
})
}
function onDelete(id) {
Fast.api.ajax({
url: `shopro/chat/question/delete/id/${id}`,
type: 'DELETE',
}, function (ret, res) {
getData()
}, function (ret, res) { })
}
onMounted(() => {
getChatConfig()
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: {
room_id: '',
title: '',
content: '',
status: 'normal',
weigh: 0,
},
rules: {
room_id: [{ required: true, message: '请选择客服分类', trigger: ['blur', 'change'] }],
title: [{ required: true, message: '请输入标题', trigger: ['blur', 'change'] }],
content: [{ required: true, message: '请输入问题内容', trigger: ['blur', 'change'] }],
},
})
function getDetail() {
Fast.api.ajax({
url: `shopro/chat/question/detail/id/${state.id}`,
type: 'GET',
}, function (ret, res) {
form.model = res.data;
nextTick(() => {
Controller.api.bindevent();
$('#questionContent').html(form.model.content)
})
return false
}, function (ret, res) { })
}
const chat = reactive({
config: {}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
chat.config = res.data
return false
}, function (ret, res) { })
}
function onConfirm() {
form.model.content = $("#questionContent").val();
proxy.$refs['formRef'].validate((valid) => {
if (valid) {
Fast.api.ajax({
url: state.type == 'add' ? 'shopro/chat/question/add' : `shopro/chat/question/edit/id/${state.id}`,
type: 'POST',
data: form.model,
}, function (ret, res) {
Fast.api.close()
}, function (ret, res) { })
}
});
}
onMounted(() => {
getChatConfig()
if (state.type == 'add') {
nextTick(() => {
Controller.api.bindevent();
})
} else if (state.type == 'edit') {
getDetail()
}
})
return {
state,
form,
chat,
onConfirm
}
}
}
createApp('addEdit', addEdit);
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
},
},
};
return Controller;
});

View File

@@ -0,0 +1,223 @@
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'moment', 'moment/locale/zh-cn'], function ($, undefined, Backend, Table, Form, Moment) {
var Controller = {
index: () => {
const { unref, reactive, onMounted } = Vue
const index = {
setup() {
const state = reactive({
id: new URLSearchParams(location.search).get('id'),
nickname: new URLSearchParams(location.search).get('nickname'),
room_id: 'admin',
room_name: '',
data: [],
})
const chat = reactive({
config: {}
})
function getChatConfig() {
Fast.api.ajax({
url: `shopro/chat/index/init`,
type: 'GET',
}, function (ret, res) {
chat.config = res.data
onCommand()
return false
}, function (ret, res) { })
}
function getData() {
pagination.page += 1;
pagination.loadStatus = 'loading';
Fast.api.ajax({
url: 'shopro/chat/record',
type: 'GET',
data: {
page: pagination.page,
list_rows: pagination.list_rows,
search: JSON.stringify({
chat_user_id: state.id,
room_id: state.room_id,
}),
},
}, function (ret, res) {
if (pagination.page == 1) {
state.data = []
}
res.data.data.forEach((item) => {
state.data.unshift(item);
});
pagination.page = res.data.current_page;
pagination.lastPage = res.data.last_page;
pagination.loadStatus = pagination.page < pagination.lastPage ? 'loadmore' : 'nomore';
if (pagination.last_id == 0) {
pagination.last_id = res.data.data.length > 0 ? res.data.data[0].id : 0;
}
return false
}, function (ret, res) { })
}
const pagination = reactive({
page: 0,
list_rows: 10,
total: 0,
last_id: 0,
lastPage: 0,
loadStatus: 'loadmore',
})
function onLoadMore() {
pagination.page < pagination.lastPage && getData();
}
function onCommand(room_id = state.room_id) {
state.room_id = room_id
state.room_name = chat.config.default_rooms?.find(item => item.value == state.room_id).name
pagination.page = 0
pagination.last_id = 0
pagination.lastPage = 0
pagination.loadStatus = 'loadmore'
getData()
}
const loadingMap = {
loadmore: {
title: '查看更多',
},
nomore: {
title: '没有更多了',
},
loading: {
title: '加载中... ',
},
};
function replaceEmoji(data) {
let newData = data;
if (typeof newData != 'object') {
let reg = /\[(.+?)\]/g; // [] 中括号
let zhEmojiName = newData.match(reg);
if (zhEmojiName) {
zhEmojiName.forEach((item) => {
let emojiFile = selEmojiFile(item);
newData = newData.replace(
item,
`<img class="record-emoji" src="${Fast.api.cdnurl(`/assets/addons/shopro/img/chat/emoji/${emojiFile}`)}" />`,
);
});
}
}
return newData;
}
function selEmojiFile(name) {
let emojiData = [
{ "name": "[笑掉牙]", "file": "xiaodiaoya.png" },
{ "name": "[可爱]", "file": "keai.png" },
{ "name": "[冷酷]", "file": "lengku.png" },
{ "name": "[闭嘴]", "file": "bizui.png" },
{ "name": "[生气]", "file": "shengqi.png" },
{ "name": "[惊恐]", "file": "jingkong.png" },
{ "name": "[瞌睡]", "file": "keshui.png" },
{ "name": "[大笑]", "file": "daxiao.png" },
{ "name": "[爱心]", "file": "aixin.png" },
{ "name": "[坏笑]", "file": "huaixiao.png" },
{ "name": "[飞吻]", "file": "feiwen.png" },
{ "name": "[疑问]", "file": "yiwen.png" },
{ "name": "[开心]", "file": "kaixin.png" },
{ "name": "[发呆]", "file": "fadai.png" },
{ "name": "[流泪]", "file": "liulei.png" },
{ "name": "[汗颜]", "file": "hanyan.png" },
{ "name": "[惊悚]", "file": "jingshu.png" },
{ "name": "[困~]", "file": "kun.png" },
{ "name": "[心碎]", "file": "xinsui.png" },
{ "name": "[天使]", "file": "tianshi.png" },
{ "name": "[晕]", "file": "yun.png" },
{ "name": "[啊]", "file": "a.png" },
{ "name": "[愤怒]", "file": "fennu.png" },
{ "name": "[睡着]", "file": "shuizhuo.png" },
{ "name": "[面无表情]", "file": "mianwubiaoqing.png" },
{ "name": "[难过]", "file": "nanguo.png" },
{ "name": "[犯困]", "file": "fankun.png" },
{ "name": "[好吃]", "file": "haochi.png" },
{ "name": "[呕吐]", "file": "outu.png" },
{ "name": "[龇牙]", "file": "ziya.png" },
{ "name": "[懵比]", "file": "mengbi.png" },
{ "name": "[白眼]", "file": "baiyan.png" },
{ "name": "[饿死]", "file": "esi.png" },
{ "name": "[凶]", "file": "xiong.png" },
{ "name": "[感冒]", "file": "ganmao.png" },
{ "name": "[流汗]", "file": "liuhan.png" },
{ "name": "[笑哭]", "file": "xiaoku.png" },
{ "name": "[流口水]", "file": "liukoushui.png" },
{ "name": "[尴尬]", "file": "ganga.png" },
{ "name": "[惊讶]", "file": "jingya.png" },
{ "name": "[大惊]", "file": "dajing.png" },
{ "name": "[不好意思]", "file": "buhaoyisi.png" },
{ "name": "[大闹]", "file": "danao.png" },
{ "name": "[不可思议]", "file": "bukesiyi.png" },
{ "name": "[爱你]", "file": "aini.png" },
{ "name": "[红心]", "file": "hongxin.png" },
{ "name": "[点赞]", "file": "dianzan.png" },
{ "name": "[恶魔]", "file": "emo.png" }
]
for (let index in emojiData) {
if (emojiData[index].name == name) {
return emojiData[index].file;
}
}
return false;
}
function showTime(item, index) {
if (state.data[index + 1]) {
let dateString = Moment(state.data[index + 1].createtime * 1000).fromNow();
if (dateString == Moment(item.createtime * 1000).fromNow()) {
return false;
} else {
dateString = Moment(item.createtime * 1000).fromNow();
return true;
}
}
return false;
};
// 格式化时间
function formatTime(time) {
let diffTime = Moment().unix() - time;
if (diffTime > 28 * 24 * 60) {
return Moment(time * 1000).format('MM/DD HH:mm');
}
if (diffTime > 360 * 28 * 24 * 60) {
return Moment(time * 1000).format('YYYY/MM/DD HH:mm');
}
return Moment(time * 1000).fromNow();
};
onMounted(() => {
getChatConfig()
})
return {
Fast,
state,
chat,
getData,
pagination,
onLoadMore,
onCommand,
loadingMap,
replaceEmoji,
showTime,
formatTime,
}
}
}
createApp('index', index);
},
};
return Controller;
});

View File

@@ -0,0 +1,154 @@
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: '' },
},
tools: {
user: {
type: 'tinputprepend',
label: '查询内容',
placeholder: '请输入查询内容',
value: {
field: 'id',
value: '',
},
options: {
data: [{
label: 'ID',
value: 'id',
},
{
label: '昵称',
value: 'nickname',
},
{
label: '手机号',
value: 'user.mobile',
}],
}
},
},
condition: {},
}
})
function getData() {
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
let search = composeFilter(tempSearch, {
nickname: 'like',
'user.mobile': 'like',
});
Fast.api.ajax({
url: 'shopro/chat/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 onRecord(item) {
Fast.api.open(`shopro/chat/record/index?id=${item.id}&nickname=${item.nickname}`, "聊天记录", {
callback() {
getData()
}
})
}
function onDelete(id) {
Fast.api.ajax({
url: `shopro/chat/user/delete/id/${id}`,
type: 'DELETE',
}, function (ret, res) {
getData()
}, function (ret, res) { })
}
onMounted(() => {
getData()
})
return {
Fast,
state,
getData,
onChangeSort,
onOpenFilter,
onChangeFilter,
pagination,
batchHandle,
onChangeSelection,
onBatchHandle,
onRecord,
onDelete
}
}
}
createApp('index', index);
},
};
return Controller;
});