advertisement.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. <template>
  2. <div class="institution">
  3. <div class="institution-main">
  4. <el-form label-position="left" label-width="auto">
  5. <el-row :gutter="24">
  6. <el-col :span="6">
  7. <el-form-item label="成员信息">
  8. <el-input
  9. v-model="form.searchValue"
  10. placeholder="输入成员信息查找"
  11. :prefix-icon="Search"
  12. />
  13. </el-form-item>
  14. </el-col>
  15. <el-col :span="6">
  16. <el-form-item label="归属机构">
  17. <el-cascader
  18. clearable
  19. style="width: 100%"
  20. v-model="form.sendDeptId"
  21. :options="institutionList"
  22. :props="tableProps"
  23. />
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="4">
  27. <el-form-item label="">
  28. <el-button type="primary" @click="getContentList">查询</el-button>
  29. <el-button type="primary" plain @click="reset">重置</el-button>
  30. </el-form-item>
  31. </el-col>
  32. </el-row>
  33. </el-form>
  34. <Table
  35. :tableData="tableData"
  36. :columns="columns"
  37. :showIndex="false"
  38. :showSelect="true"
  39. :showOperation="true"
  40. :pageInfo="pageInfo"
  41. @getList="getList"
  42. :treeProps="{ children: 'children', hasChildren: 'hasChildren' }"
  43. @select-all-change="selectAllChange"
  44. @select-change="selectChange"
  45. >
  46. <template v-slot:table-title-btn>
  47. <div>
  48. <!-- <el-button type="primary" @click="add(ruleFormRef)">
  49. <el-icon><Plus /></el-icon>添加机构</el-button
  50. > -->
  51. <el-button
  52. @click="router.push({ path: '/content/advertisement/advertisementEdit' })"
  53. ><el-icon><Position /></el-icon>发布新的广告图</el-button
  54. >
  55. </div>
  56. </template>
  57. <template v-slot:operation="scope">
  58. <el-button
  59. type="primary"
  60. link
  61. @click="editor(scope.operationData.row)"
  62. >
  63. 编辑
  64. </el-button>
  65. <el-button type="primary" link @click="del(scope.operationData.row)">
  66. 删除
  67. </el-button>
  68. </template>
  69. <template v-slot:search="scope">
  70. {{ scope.slotData.label }}
  71. </template>
  72. </Table>
  73. </div>
  74. <el-dialog v-model="dialogVisible" title="查看人数" width="1000">
  75. <Table
  76. :tableData="userTableData"
  77. :columns="userColumns"
  78. :showIndex="false"
  79. :showSelect="false"
  80. :showOperation="false"
  81. :pageInfo="userPageInfo"
  82. @getList="userGetList"
  83. :treeProps="{ children: 'children', hasChildren: 'hasChildren' }"
  84. >
  85. </Table>
  86. </el-dialog>
  87. </div>
  88. </template>
  89. <script setup lang="ts">
  90. import { ref, reactive, watch, onMounted } from "vue";
  91. import { Plus, Search, Position } from "@element-plus/icons-vue";
  92. import { useRouter } from "vue-router";
  93. // import universalTable from "../"
  94. import { ElMessageBox, ElTree, ElMessage } from "element-plus";
  95. import api from "@/api";
  96. import { h } from "vue";
  97. const router = useRouter();
  98. const filterText = ref("");
  99. const treeRef = ref<InstanceType<typeof ElTree>>();
  100. const dialogVisible = ref(false);
  101. //批量设置负责人
  102. watch(filterText, (val) => {
  103. treeRef.value!.filter(val);
  104. });
  105. let form = reactive({
  106. searchValue: "", //信息
  107. sendDeptId: "", //机构id
  108. });
  109. interface PageInfo {
  110. pageNum: number;
  111. pageSize: number;
  112. sizes: number[];
  113. total: number;
  114. show: boolean;
  115. }
  116. // import Select from "@/components/select/selectMain.vue";
  117. // import TestTable from "@/components/Table/index.vue";
  118. //业务员列表
  119. type tableType = {
  120. id: string;
  121. name: string;
  122. };
  123. const tableData = ref<tableType[]>([]);
  124. const userTableData = ref<tableType[]>([]);
  125. const tableProps = ref({
  126. value: "id",
  127. label: "name",
  128. children: "children",
  129. checkStrictly: true,
  130. });
  131. const typeformatter = (row: any, column: any, cellValue: any) => {
  132. return () =>
  133. h("div", null, [
  134. h(
  135. "h4",
  136. {
  137. onClick: () =>
  138. router.push({
  139. path: "/content/message/messageEdit",
  140. query: {
  141. id: row.id,
  142. },
  143. }),
  144. },
  145. row.title
  146. ),
  147. h("p", { class: "content" }, row.content),
  148. h("p", { class: "time" }, [
  149. h("span", null, row.createBy),
  150. h("span", null, "|"),
  151. h("span", null, row.createTime),
  152. ]),
  153. ]);
  154. };
  155. const columns = [
  156. { prop: "name", label: "发布消息", formatter: typeformatter, width: 500 },
  157. { prop: "deptName", label: "广告图",
  158. formatter: (row: any, column: any, cellValue: any) => {
  159. return () => h("img", {src:row.previewUrl}, );
  160. },
  161. },
  162. { prop: "deptName", label: "发布机构" },
  163. // { prop: "id", label: "工号" },
  164. {
  165. prop: "isLevel",
  166. label: "下级机构是否发布",
  167. formatter: (row: any, column: any, cellValue: any) => {
  168. return () => h("div", {}, row.isLevel == "1" ? "是" : "否");
  169. },
  170. },
  171. // {
  172. // prop: "username",
  173. // label: "是否强制查看",
  174. // formatter: (row: any, column: any, cellValue: any) => {
  175. // return () => h("div", {}, row.isForce == "1" ? "是" : "否");
  176. // },
  177. // },
  178. // {
  179. // prop: "viewCount",
  180. // label: "查看人数",
  181. // formatter: (row: any, column: any, cellValue: any) => {
  182. // return () =>
  183. // h(
  184. // "h4",
  185. // { class: "count", onClick: () => openDialog(row) },
  186. // row.viewCount
  187. // );
  188. // },
  189. // },
  190. ];
  191. const userColumns = [
  192. { prop: "name", label: "业务员姓名" },
  193. { prop: "mobile", label: "业务员手机号" },
  194. // { prop: "id", label: "工号" },
  195. {
  196. prop: "userId",
  197. label: "工号",
  198. },
  199. {
  200. prop: "deptName",
  201. label: "所属机构",
  202. },
  203. {
  204. prop: "createTime",
  205. label: "查看时间",
  206. },
  207. ];
  208. const contentId = ref("");
  209. const pageInfo = {
  210. pageNum: 1,
  211. pageSize: 10,
  212. sizes: [10, 20, 30, 40, 50],
  213. total: 0,
  214. show: true,
  215. };
  216. const userPageInfo = {
  217. pageNum: 1,
  218. pageSize: 10,
  219. sizes: [10, 20, 30, 40, 50],
  220. total: 0,
  221. show: true,
  222. };
  223. //分页列表功能
  224. const getList = (item: PageInfo) => {
  225. pageInfo.pageNum = item.pageNum;
  226. pageInfo.pageSize = item.pageSize;
  227. getContentList();
  228. };
  229. //分页列表功能
  230. const userGetList = (item: PageInfo) => {
  231. userPageInfo.pageNum = item.pageNum;
  232. userPageInfo.pageSize = item.pageSize;
  233. // getContenUser();
  234. };
  235. const checkTableIdList = ref([]);
  236. //表格选择事件
  237. function selectAllChange(list: any) {
  238. checkTableIdList.value = list;
  239. }
  240. function selectChange(list: any) {
  241. checkTableIdList.value = list;
  242. }
  243. //机构列表
  244. const institutionList = ref([]);
  245. const getInstitutionList = () => {
  246. api.institutionApi.institutionList({}).then((res: any) => {
  247. if (res.code === 200) institutionList.value = res.data;
  248. });
  249. };
  250. const getContentList = () => {
  251. api.advertisementApi
  252. .posterQuery({
  253. ...form,
  254. ...pageInfo,
  255. })
  256. .then((res: any) => {
  257. if (res.code === 200) {
  258. tableData.value = res.data.records;
  259. pageInfo.total = res.data.total;
  260. }
  261. });
  262. // pageInfo.pageSize=item.pageSize
  263. };
  264. function editor(item: any) {
  265. router.push({
  266. path: "/content/advertisement/advertisementEdit",
  267. query: {
  268. id: item.id,
  269. },
  270. });
  271. }
  272. function del(item: any) {
  273. ElMessageBox.confirm("确认要删除当前数据吗?", "提示", {
  274. confirmButtonText: "确认",
  275. cancelButtonText: "取消",
  276. type: "warning",
  277. center: true,
  278. })
  279. .then(() => {
  280. api.advertisementApi.posterDelet(item.id).then((res) => {
  281. if (res.code === 200) {
  282. ElMessage.success("操作成功");
  283. getContentList();
  284. }
  285. });
  286. })
  287. .catch(() => {
  288. ElMessage.warning("用户取消操作");
  289. });
  290. }
  291. const reset = (item: any) => {
  292. // ElMessage({})
  293. };
  294. onMounted(() => {
  295. getContentList();
  296. getInstitutionList(); //机构列表
  297. });
  298. </script>
  299. <style lang="scss" scoped>
  300. :deep(.count) {
  301. margin: 0 !important;
  302. color: #409eff;
  303. cursor: pointer;
  304. }
  305. :deep(.routerlick) {
  306. h4 {
  307. margin: 0 !important;
  308. color: #409eff;
  309. cursor: pointer;
  310. }
  311. p {
  312. margin: 0 !important;
  313. }
  314. .content {
  315. // width: 200px;
  316. // background-color: hotpink;
  317. // padding: 5px 10px;
  318. overflow: hidden;
  319. text-overflow: ellipsis;
  320. display: -webkit-box;
  321. -webkit-line-clamp: 2;
  322. line-clamp: 2;
  323. -webkit-box-orient: vertical;
  324. }
  325. .time {
  326. display: flex;
  327. > span {
  328. flex: none;
  329. display: flex;
  330. }
  331. > span:nth-child(2) {
  332. margin: 0 20px;
  333. }
  334. }
  335. }
  336. :deep(.table-title-btn) {
  337. display: flex;
  338. align-items: center;
  339. justify-content: space-between;
  340. > div {
  341. display: flex;
  342. }
  343. }
  344. .institution {
  345. background: #fff;
  346. width: 100%;
  347. // height: 100%;
  348. // padding: 20px;
  349. box-sizing: border-box;
  350. display: flex;
  351. .institution-main {
  352. flex: 1;
  353. // width: 80%;
  354. padding: 20px;
  355. box-sizing: border-box;
  356. }
  357. }
  358. :deep(.el-dropdown-link) {
  359. cursor: pointer;
  360. color: var(--el-color-primary);
  361. display: flex;
  362. align-items: center;
  363. margin-left: 15px;
  364. }
  365. .custom-tree-node {
  366. flex: 1;
  367. display: flex;
  368. align-items: center;
  369. justify-content: space-between;
  370. font-size: 14px;
  371. padding-right: 8px;
  372. }
  373. :deep(.el-message-box__container) {
  374. width: 100% !important;
  375. .el-message-box__message {
  376. width: 100% !important;
  377. }
  378. }
  379. </style>