391 lines
14 KiB
JavaScript
391 lines
14 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("../../common/vendor.js");
|
|
const js_sdk_validator_comment = require("../../js_sdk/validator/comment.js");
|
|
const db = common_vendor.er.database();
|
|
const dbOrderBy = "";
|
|
const dbSearchFields = [];
|
|
const pageSize = 20;
|
|
const pageCurrent = 1;
|
|
const orderByMapping = {
|
|
"ascending": "asc",
|
|
"descending": "desc"
|
|
};
|
|
const _sfc_main = {
|
|
data() {
|
|
return {
|
|
collectionList: "comment",
|
|
query: "",
|
|
where: "",
|
|
orderby: dbOrderBy,
|
|
orderByFieldName: "",
|
|
selectedIndexs: [],
|
|
options: {
|
|
pageSize,
|
|
pageCurrent,
|
|
filterData: {},
|
|
...js_sdk_validator_comment.enumConverter
|
|
},
|
|
imageStyles: {
|
|
width: 64,
|
|
height: 64
|
|
},
|
|
exportExcel: {
|
|
"filename": "comment.xls",
|
|
"type": "xls",
|
|
"fields": {
|
|
"评论内容": "content",
|
|
"root_id": "root_id",
|
|
"author_id": "author_id",
|
|
"parent_id": "parent_id",
|
|
"article_id": "article_id",
|
|
"like_count": "like_count",
|
|
"create_time": "create_time",
|
|
"update_time": "update_time",
|
|
"reply_count": "reply_count",
|
|
"ip_location": "ip_location"
|
|
}
|
|
},
|
|
exportExcelData: []
|
|
};
|
|
},
|
|
onLoad() {
|
|
this._filter = {};
|
|
},
|
|
onReady() {
|
|
this.$refs.udb.loadData();
|
|
},
|
|
methods: {
|
|
onqueryload(data) {
|
|
this.exportExcelData = data;
|
|
},
|
|
getWhere() {
|
|
const query = this.query.trim();
|
|
if (!query) {
|
|
return "";
|
|
}
|
|
const queryRe = new RegExp(query, "i");
|
|
return dbSearchFields.map((name) => queryRe + ".test(" + name + ")").join(" || ");
|
|
},
|
|
search() {
|
|
const newWhere = this.getWhere();
|
|
this.where = newWhere;
|
|
this.$nextTick(() => {
|
|
this.loadData();
|
|
});
|
|
},
|
|
loadData(clear = true) {
|
|
this.$refs.udb.loadData({
|
|
clear
|
|
});
|
|
},
|
|
onPageChanged(e) {
|
|
this.selectedIndexs.length = 0;
|
|
this.$refs.table.clearSelection();
|
|
this.$refs.udb.loadData({
|
|
current: e.current
|
|
});
|
|
},
|
|
navigateTo(url, clear) {
|
|
common_vendor.index.navigateTo({
|
|
url,
|
|
events: {
|
|
refreshData: () => {
|
|
this.loadData(clear);
|
|
}
|
|
}
|
|
});
|
|
},
|
|
// 多选处理
|
|
selectedItems() {
|
|
var dataList = this.$refs.udb.dataList;
|
|
return this.selectedIndexs.map((i) => dataList[i]._id);
|
|
},
|
|
// 批量删除
|
|
delTable() {
|
|
this.$refs.udb.remove(this.selectedItems(), {
|
|
success: (res) => {
|
|
this.$refs.table.clearSelection();
|
|
}
|
|
});
|
|
},
|
|
// 多选
|
|
selectionChange(e) {
|
|
this.selectedIndexs = e.detail.index;
|
|
},
|
|
confirmDelete(id) {
|
|
this.$refs.udb.remove(id, {
|
|
success: (res) => {
|
|
this.$refs.table.clearSelection();
|
|
}
|
|
});
|
|
},
|
|
sortChange(e, name) {
|
|
this.orderByFieldName = name;
|
|
if (e.order) {
|
|
this.orderby = name + " " + orderByMapping[e.order];
|
|
} else {
|
|
this.orderby = "";
|
|
}
|
|
this.$refs.table.clearSelection();
|
|
this.$nextTick(() => {
|
|
this.$refs.udb.loadData();
|
|
});
|
|
},
|
|
filterChange(e, name) {
|
|
this._filter[name] = {
|
|
type: e.filterType,
|
|
value: e.filter
|
|
};
|
|
let newWhere = js_sdk_validator_comment.filterToWhere(this._filter, db.command);
|
|
if (Object.keys(newWhere).length) {
|
|
this.where = newWhere;
|
|
} else {
|
|
this.where = "";
|
|
}
|
|
this.$nextTick(() => {
|
|
this.$refs.udb.loadData();
|
|
});
|
|
}
|
|
}
|
|
};
|
|
if (!Array) {
|
|
const _easycom_download_excel2 = common_vendor.resolveComponent("download-excel");
|
|
const _easycom_uni_th2 = common_vendor.resolveComponent("uni-th");
|
|
const _easycom_uni_tr2 = common_vendor.resolveComponent("uni-tr");
|
|
const _easycom_uni_td2 = common_vendor.resolveComponent("uni-td");
|
|
const _easycom_uni_dateformat2 = common_vendor.resolveComponent("uni-dateformat");
|
|
const _easycom_uni_table2 = common_vendor.resolveComponent("uni-table");
|
|
const _easycom_uni_pagination2 = common_vendor.resolveComponent("uni-pagination");
|
|
const _easycom_unicloud_db2 = common_vendor.resolveComponent("unicloud-db");
|
|
(_easycom_download_excel2 + _easycom_uni_th2 + _easycom_uni_tr2 + _easycom_uni_td2 + _easycom_uni_dateformat2 + _easycom_uni_table2 + _easycom_uni_pagination2 + _easycom_unicloud_db2)();
|
|
}
|
|
const _easycom_download_excel = () => "../../components/download-excel/download-excel.js";
|
|
const _easycom_uni_th = () => "../../uni_modules/uni-table/components/uni-th/uni-th.js";
|
|
const _easycom_uni_tr = () => "../../uni_modules/uni-table/components/uni-tr/uni-tr.js";
|
|
const _easycom_uni_td = () => "../../uni_modules/uni-table/components/uni-td/uni-td.js";
|
|
const _easycom_uni_dateformat = () => "../../uni_modules/uni-dateformat/components/uni-dateformat/uni-dateformat.js";
|
|
const _easycom_uni_table = () => "../../uni_modules/uni-table/components/uni-table/uni-table.js";
|
|
const _easycom_uni_pagination = () => "../../uni_modules/uni-pagination/components/uni-pagination/uni-pagination.js";
|
|
const _easycom_unicloud_db = () => "../../node-modules/@dcloudio/uni-components/lib/unicloud-db/unicloud-db.js";
|
|
if (!Math) {
|
|
(_easycom_download_excel + _easycom_uni_th + _easycom_uni_tr + _easycom_uni_td + _easycom_uni_dateformat + _easycom_uni_table + _easycom_uni_pagination + _easycom_unicloud_db)();
|
|
}
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
return {
|
|
a: common_vendor.o((...args) => $options.search && $options.search(...args)),
|
|
b: $data.query,
|
|
c: common_vendor.o(($event) => $data.query = $event.detail.value),
|
|
d: common_vendor.o((...args) => $options.search && $options.search(...args)),
|
|
e: common_vendor.o(($event) => $options.navigateTo("./add")),
|
|
f: !$data.selectedIndexs.length,
|
|
g: common_vendor.o((...args) => $options.delTable && $options.delTable(...args)),
|
|
h: common_vendor.p({
|
|
fields: $data.exportExcel.fields,
|
|
data: $data.exportExcelData,
|
|
type: $data.exportExcel.type,
|
|
name: $data.exportExcel.filename
|
|
}),
|
|
i: common_vendor.w(({
|
|
data,
|
|
pagination,
|
|
loading,
|
|
error,
|
|
options
|
|
}, s0, i0) => {
|
|
return {
|
|
a: "c14b1290-4-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
b: "c14b1290-5-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
c: "c14b1290-6-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
d: "c14b1290-7-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
e: "c14b1290-8-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
f: "c14b1290-9-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
g: "c14b1290-10-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
h: "c14b1290-11-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
i: "c14b1290-12-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
j: "c14b1290-13-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
k: "c14b1290-14-" + i0 + "," + ("c14b1290-3-" + i0),
|
|
l: "c14b1290-3-" + i0 + "," + ("c14b1290-2-" + i0),
|
|
m: common_vendor.f(data, (item, index, i1) => {
|
|
return {
|
|
a: common_vendor.t(item.content),
|
|
b: "c14b1290-16-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
c: common_vendor.t(item.root_id),
|
|
d: "c14b1290-17-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
e: common_vendor.t(item.author_id),
|
|
f: "c14b1290-18-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
g: common_vendor.t(item.parent_id),
|
|
h: "c14b1290-19-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
i: common_vendor.t(item.article_id),
|
|
j: "c14b1290-20-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
k: common_vendor.t(item.like_count),
|
|
l: "c14b1290-21-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
m: "c14b1290-23-" + i0 + "-" + i1 + "," + ("c14b1290-22-" + i0 + "-" + i1),
|
|
n: common_vendor.p({
|
|
threshold: [0, 0],
|
|
date: item.create_time
|
|
}),
|
|
o: "c14b1290-22-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
p: "c14b1290-25-" + i0 + "-" + i1 + "," + ("c14b1290-24-" + i0 + "-" + i1),
|
|
q: common_vendor.p({
|
|
threshold: [0, 0],
|
|
date: item.update_time
|
|
}),
|
|
r: "c14b1290-24-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
s: common_vendor.t(item.reply_count),
|
|
t: "c14b1290-26-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
v: common_vendor.t(item.ip_location),
|
|
w: "c14b1290-27-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
x: common_vendor.o(($event) => $options.navigateTo("./edit?id=" + item._id, false), index),
|
|
y: common_vendor.o(($event) => $options.confirmDelete(item._id), index),
|
|
z: "c14b1290-28-" + i0 + "-" + i1 + "," + ("c14b1290-15-" + i0 + "-" + i1),
|
|
A: index,
|
|
B: "c14b1290-15-" + i0 + "-" + i1 + "," + ("c14b1290-2-" + i0)
|
|
};
|
|
}),
|
|
n: common_vendor.sr("table", "c14b1290-2-" + i0 + ",c14b1290-1"),
|
|
o: "c14b1290-2-" + i0 + ",c14b1290-1",
|
|
p: common_vendor.p({
|
|
loading,
|
|
emptyText: error.message || "没有更多数据",
|
|
border: true,
|
|
stripe: true,
|
|
type: "selection"
|
|
}),
|
|
q: "c14b1290-29-" + i0 + ",c14b1290-1",
|
|
r: common_vendor.o(($event) => pagination.current = $event),
|
|
s: common_vendor.p({
|
|
["show-icon"]: true,
|
|
["page-size"]: pagination.size,
|
|
total: pagination.count,
|
|
modelValue: pagination.current
|
|
}),
|
|
t: i0,
|
|
v: s0
|
|
};
|
|
}, {
|
|
name: "d",
|
|
path: "i",
|
|
vueId: "c14b1290-1"
|
|
}),
|
|
j: common_vendor.o(($event) => $options.filterChange($event, "content")),
|
|
k: common_vendor.o(($event) => $options.sortChange($event, "content")),
|
|
l: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "search",
|
|
sortable: true
|
|
}),
|
|
m: common_vendor.o(($event) => $options.filterChange($event, "root_id")),
|
|
n: common_vendor.o(($event) => $options.sortChange($event, "root_id")),
|
|
o: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "search",
|
|
sortable: true
|
|
}),
|
|
p: common_vendor.o(($event) => $options.sortChange($event, "author_id")),
|
|
q: common_vendor.p({
|
|
align: "center",
|
|
sortable: true
|
|
}),
|
|
r: common_vendor.o(($event) => $options.filterChange($event, "parent_id")),
|
|
s: common_vendor.o(($event) => $options.sortChange($event, "parent_id")),
|
|
t: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "search",
|
|
sortable: true
|
|
}),
|
|
v: common_vendor.o(($event) => $options.sortChange($event, "article_id")),
|
|
w: common_vendor.p({
|
|
align: "center",
|
|
sortable: true
|
|
}),
|
|
x: common_vendor.o(($event) => $options.filterChange($event, "like_count")),
|
|
y: common_vendor.o(($event) => $options.sortChange($event, "like_count")),
|
|
z: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "range",
|
|
sortable: true
|
|
}),
|
|
A: common_vendor.o(($event) => $options.filterChange($event, "create_time")),
|
|
B: common_vendor.o(($event) => $options.sortChange($event, "create_time")),
|
|
C: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "timestamp",
|
|
sortable: true
|
|
}),
|
|
D: common_vendor.o(($event) => $options.filterChange($event, "update_time")),
|
|
E: common_vendor.o(($event) => $options.sortChange($event, "update_time")),
|
|
F: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "timestamp",
|
|
sortable: true
|
|
}),
|
|
G: common_vendor.o(($event) => $options.filterChange($event, "reply_count")),
|
|
H: common_vendor.o(($event) => $options.sortChange($event, "reply_count")),
|
|
I: common_vendor.p({
|
|
align: "center",
|
|
["filter-type"]: "range",
|
|
sortable: true
|
|
}),
|
|
J: common_vendor.o(($event) => $options.sortChange($event, "ip_location")),
|
|
K: common_vendor.p({
|
|
align: "center",
|
|
sortable: true
|
|
}),
|
|
L: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
M: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
N: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
O: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
P: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
Q: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
R: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
S: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
T: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
U: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
V: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
W: common_vendor.p({
|
|
align: "center"
|
|
}),
|
|
X: common_vendor.o($options.selectionChange),
|
|
Y: common_vendor.o($options.onPageChanged),
|
|
Z: common_vendor.sr("udb", "c14b1290-1"),
|
|
aa: common_vendor.o($options.onqueryload),
|
|
ab: common_vendor.p({
|
|
collection: $data.collectionList,
|
|
field: "content,root_id,author_id,parent_id,article_id,like_count,create_time,update_time,reply_count,ip_location",
|
|
where: $data.where,
|
|
["page-data"]: "replace",
|
|
orderby: $data.orderby,
|
|
getcount: true,
|
|
["page-size"]: $data.options.pageSize,
|
|
["page-current"]: $data.options.pageCurrent,
|
|
options: $data.options,
|
|
loadtime: "manual"
|
|
})
|
|
};
|
|
}
|
|
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
|
wx.createPage(MiniProgramPage);
|
|
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/comment/list.js.map
|