advertisement.vue 10 KB

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