UNPKG

@cmstops/pro-compo

Version:

[物料平台文档中心](https://arco.design/docs/material/guide)

234 lines (233 loc) 7.95 kB
"use strict"; var vue = require("vue"); var webVue = require("@arco-design/web-vue"); var component = require("../../../typeIcons/component.js"); var index = require("./MediaFilter/index.js"); var batch = require("../../../hooks/batch.js"); var api = require("../../script/api.js"); const _hoisted_1 = { class: "view-all-column-container" }; const _hoisted_2 = { class: "content-table-view" }; const _hoisted_3 = { class: "title-span" }; const _hoisted_4 = ["onClick"]; const _hoisted_5 = { class: "title" }; const _hoisted_6 = { class: "bottom-view" }; const _hoisted_7 = { class: "left" }; const _sfc_main = vue.defineComponent({ ...{ name: "LiveList" }, __name: "index", props: { maxSelect: {}, outsideSelectData: {}, defaultSelectedData: {}, userInfo: {} }, emits: ["change"], setup(__props, { emit: __emit }) { var _a, _b, _c; const emit = __emit; const props = __props; const _maxSelect = props.maxSelect || 100; const selectedData = vue.ref([]); const group_id = vue.ref("all"); const mediaFileData = vue.ref([]); const dataLoading = vue.ref(false); const page = vue.ref({ index: 1, size: 10, total: 0 }); const filter = vue.ref(null); const mpName = ((_c = (_b = (_a = window.situoyun) == null ? void 0 : _a.config) == null ? void 0 : _b.oem_config) == null ? void 0 : _c.mp_name) || "\u516C\u4F17\u53F7"; const columns = [ { title: "\u6807\u9898", dataIndex: "title", slotName: "title" }, { title: `\u6240\u5C5E${mpName}`, dataIndex: "account_name", slotName: "account_name" }, { title: "\u53D1\u5E03\u65F6\u95F4", dataIndex: "pub_time", slotName: "pub_time" } ]; const scrollPercent = { y: "100%" }; const tempSelectedData = vue.computed(() => { return props.defaultSelectedData || []; }); const search = (_filter) => { if (_filter.account_uid || _filter.wd || _filter.order === 0 || _filter.order === 1) { filter.value = { ..._filter }; } else { filter.value = null; } page.value.index = 1; loadData(); }; const loadData = async () => { let params = { page: page.value.index, page_size: page.value.size }; if (filter.value) { params = { ...params, ...filter.value }; } dataLoading.value = true; const { code, message } = await api.getMpContentList( props.userInfo.BASE_API, params ); dataLoading.value = false; if (code === 0) { page.value.total = message.total; mediaFileData.value = message.list.map((v) => { v.catalog = "mp_content"; v.target_id = v.id; v.target_type = 16; v._type = 3; return v; }) || []; page.value.total = message.total || message.count; } }; const pageChangeHandle = (index2) => { page.value.index = index2; loadData(); }; const clickCheckbox = (e, record) => { e.stopPropagation(); e.preventDefault(); selectData(record); }; const selectTableCell = (record) => { selectData(record); }; const selectData = (record) => { if (checkSameAdd(record)) { webVue.Message.warning({ content: "\u8BF7\u52FF\u6DFB\u52A0\u91CD\u590D\u6570\u636E", duration: 3e3 }); return; } addDataToSelectedList(record); }; const checkSameAdd = (record) => { const selected = props.outsideSelectData; if (!selected.length) return false; return selected.map((row) => row.id).includes(record.id); }; const addDataToSelectedList = async (record) => { const index2 = selectedData.value.findIndex((v) => v.id === record.id); if (selectedData.value.length < _maxSelect) { if (index2 === -1) { selectedData.value.push(record); } else { selectedData.value.splice(index2, 1); } emitChange(); } else { if (index2 === -1) { selectedData.value.splice(selectedData.value.length - 1, 1); selectedData.value.push(record); } else { selectedData.value.splice(index2, 1); } webVue.Message.warning({ content: "\u5DF2\u8FBE\u5230\u9009\u62E9\u6570\u91CF\u7684\u4E0A\u9650", duration: 3e3 }); emitChange(); } }; const emitChange = () => { emit("change", selectedData.value); }; const { isItemChecked, hoverBatchBox, tableCellMouseEnter, tableCellMouseLeave } = batch(); vue.watch( () => tempSelectedData.value, (val) => { selectedData.value = val; } ); vue.watch( () => group_id.value, () => { page.value.index = 1; loadData(); } ); vue.onMounted(() => { loadData(); }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock("div", _hoisted_1, [ vue.createVNode(index, { group_id: group_id.value, "onUpdate:group_id": _cache[0] || (_cache[0] = ($event) => group_id.value = $event), "user-info": _ctx.userInfo, onSearch: search }, null, 8, ["group_id", "user-info"]), vue.createElementVNode("div", _hoisted_2, [ vue.createVNode(vue.unref(webVue.Table), { columns, scroll: scrollPercent, pagination: false, bordered: false, data: mediaFileData.value, loading: dataLoading.value, onCellMouseEnter: vue.unref(tableCellMouseEnter), onCellMouseLeave: vue.unref(tableCellMouseLeave), onRowClick: selectTableCell }, { title: vue.withCtx(({ record }) => [ vue.createElementVNode("span", _hoisted_3, [ vue.unref(hoverBatchBox)(selectedData.value, record) ? (vue.openBlock(), vue.createElementBlock("span", { key: 0, onClick: vue.withModifiers(($event) => clickCheckbox($event, record), ["stop"]) }, [ vue.createVNode(vue.unref(webVue.Checkbox), { class: "icon", "model-value": vue.unref(isItemChecked)(selectedData.value, record) }, null, 8, ["model-value"]) ], 8, _hoisted_4)) : (vue.openBlock(), vue.createBlock(component, { key: 1, class: "icon", doc: true, type: record.series }, null, 8, ["type"])), vue.createElementVNode("span", _hoisted_5, vue.toDisplayString(record.title || record.alias || "--"), 1) ]) ]), account_name: vue.withCtx(({ record }) => [ vue.createElementVNode("span", null, vue.toDisplayString(record.account_name || record.mp_user_name), 1) ]), pub_time: vue.withCtx(({ record }) => [ vue.createElementVNode("span", null, vue.toDisplayString(record.pub_time), 1) ]), _: 1 }, 8, ["data", "loading", "onCellMouseEnter", "onCellMouseLeave"]) ]), vue.createElementVNode("div", _hoisted_6, [ vue.createElementVNode("div", _hoisted_7, [ vue.renderSlot(_ctx.$slots, "store"), vue.withDirectives(vue.createVNode(vue.unref(webVue.Pagination), { current: page.value.index, "page-size": page.value.size, total: page.value.total, onChange: pageChangeHandle }, null, 8, ["current", "page-size", "total"]), [ [vue.vShow, mediaFileData.value.length > 0] ]) ]), vue.renderSlot(_ctx.$slots, "options") ]) ]); }; } }); module.exports = _sfc_main;