index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737
  1. <template>
  2. <div class="app-container">
  3. <el-row :gutter="10">
  4. <!-- <el-col :span="4" :xs="24">
  5. <org-tree v-model="queryParams.orgId" @defaultKey="getDefaultKey" @checkChange="checkChange"
  6. @click="clickTreeNode"></org-tree>
  7. </el-col> -->
  8. <el-col :span="24" :xs="24">
  9. <div class="main-right-box">
  10. <div class="main-search-box">
  11. <el-form
  12. :model="queryParams"
  13. ref="queryForm"
  14. size="small"
  15. :inline="true"
  16. v-show="showSearch"
  17. >
  18. <el-form-item label="创建机构">
  19. <org-tree
  20. v-model="queryParams.orgId"
  21. @defaultKey="getDefaultKey"
  22. @checkChange="checkChange"
  23. @click="clickTreeNode"
  24. ref="orgTree"
  25. ></org-tree>
  26. </el-form-item>
  27. <el-form-item label="标题" prop="title">
  28. <el-input
  29. v-model="queryParams.title"
  30. placeholder="请输入标题"
  31. />
  32. </el-form-item>
  33. <el-form-item label="发布时间" prop="planStartTime">
  34. <el-date-picker
  35. v-model="queryParams.dateRange"
  36. style="width: 240px"
  37. value-format="yyyy-MM-dd HH:mm:ss"
  38. type="daterange"
  39. range-separator="-"
  40. start-placeholder="开始日期"
  41. end-placeholder="结束日期"
  42. :default-time="['00:00:00', '23:59:59']"
  43. ></el-date-picker>
  44. </el-form-item>
  45. <el-form-item label="状态" prop="messagStatus">
  46. <el-select
  47. v-model="queryParams.messagStatus"
  48. placeholder="请选择状态"
  49. clearable
  50. >
  51. <el-option
  52. v-for="dict in dict.type.message_status"
  53. :key="dict.value"
  54. :label="dict.label"
  55. :value="dict.value"
  56. />
  57. </el-select>
  58. </el-form-item>
  59. <!-- <el-form-item>
  60. <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  61. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  62. </el-form-item> -->
  63. </el-form>
  64. <el-row :gutter="10">
  65. <el-col :span="1.5">
  66. <el-button
  67. type="primary"
  68. icon="el-icon-search"
  69. size="mini"
  70. @click="handleQuery"
  71. >搜索
  72. </el-button
  73. >
  74. </el-col>
  75. <el-col :span="1.5">
  76. <el-button
  77. type="primary"
  78. icon="el-icon-refresh"
  79. size="mini"
  80. @click="resetQuery"
  81. >重置
  82. </el-button
  83. >
  84. </el-col>
  85. <el-col :span="1.5">
  86. <el-button
  87. type="primary"
  88. icon="el-icon-plus"
  89. size="mini"
  90. @click="handleAdd"
  91. v-hasPermi="['core:notification:add']"
  92. >新增
  93. </el-button
  94. >
  95. </el-col>
  96. <right-toolbar
  97. :showSearch.sync="showSearch"
  98. @queryTable="getList"
  99. ></right-toolbar>
  100. </el-row>
  101. </div>
  102. <el-table
  103. v-loading="loading"
  104. :data="notificationList"
  105. border
  106. height="700"
  107. size="small"
  108. >
  109. <el-table-column
  110. label="序号"
  111. width="80"
  112. type="index"
  113. align="center"
  114. >
  115. <template slot-scope="scope">
  116. <span>{{
  117. (queryParams.pageNum - 1) * queryParams.pageSize +
  118. scope.$index +
  119. 1
  120. }}</span>
  121. </template>
  122. </el-table-column>
  123. <el-table-column
  124. label="创建机构"
  125. align="center"
  126. width="250"
  127. prop="orgName"
  128. />
  129. <el-table-column
  130. label="消息类型"
  131. align="center"
  132. width="200"
  133. prop="messagType"
  134. >
  135. <template slot-scope="scope">
  136. <dict-tag
  137. :options="dict.type.messag_type"
  138. :value="scope.row.messagType"
  139. />
  140. </template>
  141. </el-table-column>
  142. <el-table-column
  143. label="机构类型"
  144. width="200"
  145. align="center"
  146. prop="execOrgType"
  147. >
  148. <template slot-scope="scope">
  149. <dict-tag
  150. :options="dict.type.sys_org_type"
  151. :value="scope.row.tagOrgType"
  152. />
  153. </template>
  154. </el-table-column>
  155. <el-table-column prop="tagRoleIds" width="180" label="目标角色">
  156. <template slot-scope="r">
  157. <span>{{ getRolename(r.row.tagRoleIds) }}</span>
  158. </template>
  159. </el-table-column>
  160. <el-table-column
  161. label="标题"
  162. align="center"
  163. width="200"
  164. prop="title"
  165. >
  166. <template slot-scope="r"
  167. ><p :title="r.row.title" class="line-style">
  168. {{ r.row.title }}
  169. </p></template
  170. >
  171. </el-table-column>
  172. <el-table-column label="创建人" align="center" prop="createBy"/>
  173. <el-table-column
  174. label="发布时间"
  175. align="center"
  176. prop="publishTime"
  177. width="180"
  178. >
  179. <!-- <template slot-scope="scope">
  180. <span>{{ parseTime(scope.row.publishTime, '{y}-{m}-{d}') }}</span>
  181. </template>-->
  182. </el-table-column>
  183. <el-table-column label="状态" align="center" prop="messagStatus">
  184. <template slot-scope="scope">
  185. <dict-tag
  186. :options="dict.type.message_status"
  187. :value="scope.row.messagStatus"
  188. />
  189. </template>
  190. </el-table-column>
  191. <el-table-column
  192. label="操作"
  193. align="center"
  194. width="280"
  195. fixed="right"
  196. class-name="small-padding fixed-width"
  197. >
  198. <template slot-scope="scope">
  199. <el-button
  200. size="mini"
  201. type="text"
  202. @click="lookThisOne(scope.row)"
  203. icon="el-icon-view"
  204. v-hasPermi="['core:notification:query']"
  205. >详情
  206. </el-button
  207. >
  208. <el-button
  209. size="mini"
  210. type="text"
  211. @click="handleUpdate(scope.row)"
  212. v-hasPermi="['core:notification:edit']"
  213. v-if="scope.row.messagStatus == '0'"
  214. icon="el-icon-edit-outline"
  215. >编辑
  216. </el-button
  217. >
  218. <el-button
  219. size="mini"
  220. type="text"
  221. @click="handleDelete(scope.row)"
  222. v-hasPermi="['core:notification:remove']"
  223. v-if="
  224. scope.row.messagStatus == '0' &&
  225. loginOrgId == scope.row.orgId
  226. "
  227. icon="el-icon-delete"
  228. >删除
  229. </el-button
  230. >
  231. <el-button
  232. size="mini"
  233. type="text"
  234. @click="publish(scope.row)"
  235. v-hasPermi="['core:notification:publish']"
  236. v-if="
  237. scope.row.messagStatus == '0' &&
  238. loginOrgId == scope.row.orgId
  239. "
  240. >发布
  241. </el-button
  242. >
  243. <el-button
  244. size="mini"
  245. type="text"
  246. @click="publish(scope.row)"
  247. v-hasPermi="['core:notification:cancelPublish']"
  248. v-if="
  249. scope.row.messagStatus == '1' &&
  250. loginOrgId == scope.row.orgId
  251. "
  252. icon="el-icon-arrow-down"
  253. >取消发布
  254. </el-button
  255. >
  256. </template>
  257. </el-table-column>
  258. </el-table>
  259. <pagination
  260. v-show="total > 0"
  261. :total="total"
  262. :page.sync="queryParams.pageNum"
  263. :limit.sync="queryParams.pageSize"
  264. @pagination="getList"
  265. />
  266. </div>
  267. </el-col>
  268. </el-row>
  269. <!-- 添加或修改公告通知对话框 -->
  270. <DialogCom
  271. :title="title"
  272. :visible.sync="open"
  273. width="800px"
  274. append-to-body
  275. @close="handleClose"
  276. >
  277. <el-form ref="form" :model="form" :rules="rules" label-width="120px">
  278. <el-form-item label="标题" prop="title">
  279. <el-input
  280. v-model="form.title"
  281. placeholder="请输入标题"
  282. :disabled="!isSubmit"
  283. :maxlength="100"
  284. />
  285. </el-form-item>
  286. <el-form-item label="消息类型" prop="messagType">
  287. <el-select
  288. v-model="form.messagType"
  289. placeholder="请选择消息类型"
  290. style="width: 100%"
  291. :disabled="!isSubmit"
  292. @change="showOrHidden()"
  293. >
  294. <el-option
  295. v-for="dict in dict.type.messag_type"
  296. :key="dict.value"
  297. :label="dict.label"
  298. :value="dict.value"
  299. ></el-option>
  300. </el-select>
  301. </el-form-item>
  302. <el-form-item label="机构类型" prop="tagOrgType">
  303. <el-select
  304. v-model="form.tagOrgType"
  305. placeholder="请选择机构类型"
  306. :disabled="!isSubmit"
  307. style="width: 100%"
  308. @change="execOrgTypeChanged()"
  309. >
  310. <el-option
  311. v-for="dict in dict.type.sys_org_type"
  312. :key="dict.value"
  313. :label="dict.label"
  314. :value="dict.value"
  315. >
  316. </el-option>
  317. </el-select>
  318. </el-form-item>
  319. <el-form-item label="目标机构" prop="tagOrgIds">
  320. <!-- <org-tree-select :queryData="form.tagOrgType" ref="orgTreeSelect" @selectNode="queryNode"
  321. :placeholder="'请选择目标机构'" :disable="true"></org-tree-select>-->
  322. <org-tree-select
  323. trigger="hover"
  324. v-model="form.tagOrgIds"
  325. :queryData="parseInt(form.tagOrgType)"
  326. ref="orgTreeSelect"
  327. :enabledCheckOrgTypes="parseInt(form.tagOrgType)"
  328. :disable="true"
  329. :disabled="!isSubmit"
  330. @selectNode="selectNodeId"
  331. >
  332. </org-tree-select>
  333. </el-form-item>
  334. <!-- </el-form-item>-->
  335. <el-form-item label="目标角色" v-if="isShow" prop="tagRoleIds"
  336. :rules="{required: isShow?true:false, message: '请选择目标角色', trigger: 'blur'}">
  337. <el-select
  338. v-model="form.tagRoleIds"
  339. placeholder="请选择目标角色"
  340. :disabled="!isSubmit"
  341. multiple
  342. >
  343. <el-option
  344. v-for="item in roleList"
  345. :key="item.id"
  346. :label="item.name"
  347. :value="item.id"
  348. ></el-option>
  349. </el-select>
  350. </el-form-item>
  351. <el-form-item label="内容" prop="content">
  352. <el-input
  353. v-model="form.content"
  354. type="textarea"
  355. placeholder="请输入内容"
  356. :disabled="!isSubmit"
  357. :autosize="{ minRows: 6, maxRows: 10 }"
  358. :maxlength="2000"
  359. show-word-limit
  360. />
  361. </el-form-item>
  362. <el-form-item label="附件" prop="fileList">
  363. <K-file-upload
  364. ref="upload"
  365. :defaultValue="formFileListDefualtValue"
  366. :disabled="!isSubmit"
  367. :isShowUploadBtn="!isSubmit ? false : true"
  368. v-model="form.fileList"
  369. />
  370. </el-form-item>
  371. </el-form>
  372. <div slot="footer" class="dialog-footer">
  373. <el-button type="primary" v-if="isSubmit" @click="submitForm"
  374. >确 定
  375. </el-button
  376. >
  377. <el-button @click="cancel" v-if="isSubmit">取 消</el-button>
  378. <el-button @click="cancel" v-else>关 闭</el-button>
  379. </div>
  380. </DialogCom>
  381. </div>
  382. </template>
  383. <script>
  384. import {
  385. listNotification,
  386. getNotification,
  387. delNotification,
  388. addNotification,
  389. updateNotification,
  390. roleList,
  391. publishNotification,
  392. } from "@/api/core/notification";
  393. // import OrgTree from "@/components/orgTree";
  394. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  395. import KFileUpload from "@/components/K-FileUpload/index.vue";
  396. import OrgTreeSelect from "@/components/orgTreeSelect";
  397. import {mapGetters} from "vuex";
  398. export default {
  399. components: {OrgTree, KFileUpload, OrgTreeSelect},
  400. name: "Notification",
  401. dicts: ["messag_type", "message_status", "sys_org_type"],
  402. data() {
  403. return {
  404. // 遮罩层
  405. loading: true,
  406. // 选中数组
  407. ids: [],
  408. // 非单个停用
  409. single: true,
  410. // 非多个停用
  411. multiple: true,
  412. // 显示搜索条件
  413. showSearch: true,
  414. // 总条数
  415. total: 0,
  416. // 公告通知表格数据
  417. notificationList: [],
  418. // 弹出层标题
  419. title: "",
  420. // 是否显示弹出层
  421. open: false,
  422. orgId: null,
  423. loginOrgId: null,
  424. // 查询参数
  425. queryParams: {
  426. pageNum: 1,
  427. pageSize: 10,
  428. title: null,
  429. dateRange: [],
  430. messagStatus: null,
  431. checkSub: true,
  432. },
  433. isShow: false,
  434. isSubmit: true,
  435. roleList: [],
  436. roleListInit: [],
  437. formFileListDefualtValue: [],
  438. // 表单参数
  439. form: {
  440. title: null,
  441. messagType: null,
  442. tagOrgType: null,
  443. tagOrgIds: [],
  444. content: null
  445. },
  446. // 表单校验
  447. rules: {
  448. title: [{required: true, message: "请输入标题"}],
  449. messagType: [{required: true, message: "请选择消息类型"}],
  450. tagOrgType: [{required: true, message: "请选择机构类型"}],
  451. tagOrgIds: [{required: true, message: "请选择目标机构", trigger: 'change'}],
  452. content: [{required: true, message: "请输入内容"}],
  453. },
  454. };
  455. },
  456. computed: {
  457. ...mapGetters(["orgId"]),
  458. },
  459. created() {
  460. this.orgId = this.$store.getters.orgId;
  461. this.loginOrgId = this.$store.getters.orgId;
  462. this.queryParams.orgId = this.$store.getters.orgId;
  463. this.getList();
  464. this.initRoleList();
  465. },
  466. methods: {
  467. selectNodeId(val){
  468. this.form.tagOrgIds=val.map(item=>item.id)
  469. this.$refs.form.validateField('tagOrgIds',(errorMessage)=>{
  470. console.log(errorMessage,'errorMessage')
  471. if(!errorMessage){
  472. }else{
  473. return false
  474. }
  475. })
  476. },
  477. /** 查询公告通知列表 */
  478. getList() {
  479. this.loading = true;
  480. listNotification(this.queryParams).then((response) => {
  481. this.notificationList = response.rows;
  482. this.total = response.total;
  483. this.loading = false;
  484. });
  485. },
  486. getRolename(roleIds) {
  487. if (roleIds != null && roleIds.length > 0) {
  488. return roleIds
  489. .map((v) => {
  490. if (this.roleListInit.find((item) => item.id === v)) {
  491. return this.roleListInit.find((item) => item.id === v).name;
  492. } else {
  493. return "";
  494. }
  495. })
  496. .join(",");
  497. } else {
  498. return "";
  499. }
  500. },
  501. // 取消按钮
  502. cancel() {
  503. this.open = false;
  504. this.$refs.orgTreeSelect.clear();
  505. //this.roleList=[];
  506. this.reset();
  507. this.isSubmit = true;
  508. this.isShow = false;
  509. },
  510. handleClose() {
  511. this.cancel();
  512. },
  513. queryNode(nodes) {
  514. this.form.tagOrgIds = JSON.parse(nodes).map((v) => {
  515. return v.id;
  516. });
  517. },
  518. // 表单重置
  519. reset() {
  520. this.form = {
  521. id: null,
  522. orgId: null,
  523. orgName: null,
  524. orgPath: null,
  525. title: null,
  526. content: null,
  527. messagType: null,
  528. tagOrgIds: [],
  529. tagRoleIds: null,
  530. createBy: null,
  531. createTime: null,
  532. publishTime: null,
  533. messagStatus: null,
  534. fileList: [],
  535. };
  536. this.resetForm("form");
  537. },
  538. /** 搜索按钮操作 */
  539. handleQuery() {
  540. this.queryParams.pageNum = 1;
  541. this.getList();
  542. },
  543. /** 重置按钮操作 */
  544. resetQuery() {
  545. this.resetForm("queryForm");
  546. this.queryParams.orgId = this.$store.getters.orgId;
  547. this.queryParams.checkSub = true;
  548. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  549. this.queryParams.dateRange = [];
  550. this.handleQuery();
  551. },
  552. // 多选框选中数据
  553. handleSelectionChange(selection) {
  554. this.ids = selection.map((item) => item.id);
  555. this.single = selection.length !== 1;
  556. this.multiple = !selection.length;
  557. },
  558. /** 新增按钮操作 */
  559. handleAdd() {
  560. this.reset();
  561. this.initRoleList();
  562. this.formFileListDefualtValue = [];
  563. this.open = true;
  564. this.isShow = false;
  565. this.title = "添加公告通知";
  566. },
  567. /** 修改按钮操作 */
  568. handleUpdate(row) {
  569. this.reset();
  570. const id = row.id || this.ids;
  571. getNotification(id).then((response) => {
  572. this.form = response.data;
  573. /* if(this.form.tagRoleIds!=null&&this.form.tagRoleIds.length>0){
  574. this.isShow=true;
  575. }*/
  576. if (this.form.messagType == 1) {
  577. this.isShow = true;
  578. }
  579. roleList(this.form.tagOrgType).then((res) => {
  580. this.roleList = res.data;
  581. });
  582. this.formFileListDefualtValue = this.form.fileList;
  583. this.open = true;
  584. this.title = "编辑公告通知";
  585. });
  586. },
  587. lookThisOne(row) {
  588. this.reset();
  589. this.isSubmit = false;
  590. const id = row.id || this.ids;
  591. getNotification(id).then((response) => {
  592. this.form = response.data;
  593. if (this.form.messagType == 1) {
  594. this.isShow = true;
  595. }
  596. /* if(this.form.tagRoleIds!=null&&this.form.tagRoleIds.length>0){
  597. this.isShow=true;
  598. }*/
  599. roleList(this.form.tagOrgType).then((res) => {
  600. this.roleList = res.data;
  601. });
  602. this.formFileListDefualtValue = this.form.fileList;
  603. this.open = true;
  604. this.title = "公告通知详情";
  605. });
  606. },
  607. /** 提交按钮 */
  608. submitForm() {
  609. this.form.orgId = this.orgId;
  610. this.$refs["form"].validate((valid) => {
  611. if (valid) {
  612. if (this.form.id != null) {
  613. updateNotification(this.form).then((response) => {
  614. this.$modal.msgSuccess("修改成功");
  615. this.open = false;
  616. this.$refs.orgTreeSelect.clear();
  617. this.reset();
  618. this.$refs["upload"].clearFiles();
  619. this.form.fileList = [];
  620. this.getList();
  621. });
  622. } else {
  623. addNotification(this.form).then((response) => {
  624. this.$modal.msgSuccess("新增成功");
  625. this.open = false;
  626. this.$refs.orgTreeSelect.clear();
  627. this.reset();
  628. this.form.fileList = [];
  629. this.$refs["upload"].clearFiles();
  630. this.getList();
  631. });
  632. }
  633. }
  634. });
  635. },
  636. /** 删除按钮操作 */
  637. handleDelete(row) {
  638. const ids = row.id || this.ids;
  639. this.$modal
  640. .confirm("是否确认删除该公告通知?")
  641. .then(function () {
  642. return delNotification(ids);
  643. })
  644. .then(() => {
  645. this.getList();
  646. this.$modal.msgSuccess("删除成功");
  647. })
  648. .catch(() => {
  649. });
  650. },
  651. publish(row) {
  652. const id = row.id;
  653. const messagStatus = row.messagStatus;
  654. let message = "";
  655. let returnMessage = "";
  656. if (messagStatus == 0) {
  657. message = "你确定要发布该消息吗?";
  658. returnMessage = "发布成功";
  659. } else {
  660. message = "你确定要取消发布该消息吗?";
  661. returnMessage = "取消发布成功";
  662. }
  663. this.$modal
  664. .confirm(message)
  665. .then(function () {
  666. return publishNotification(id);
  667. })
  668. .then(() => {
  669. this.getList();
  670. this.$modal.msgSuccess(returnMessage);
  671. })
  672. .catch(() => {
  673. });
  674. },
  675. getDefaultKey(key) {
  676. this.queryParams.orgId = key;
  677. this.getList();
  678. },
  679. checkChange(state) {
  680. this.queryParams.checkSub = state;
  681. this.handleQuery();
  682. },
  683. // 节点单击事件
  684. clickTreeNode(data) {
  685. this.queryParams.orgId = data.id;
  686. this.orgName = data.name;
  687. this.handleQuery();
  688. },
  689. execOrgTypeChanged(row) {
  690. this.form.tagRoleIds = [];
  691. this.$refs.orgTreeSelect.clear();
  692. this.initRoleList(this.form.tagOrgType);
  693. },
  694. initRoleList(query) {
  695. this.form.tagRoleIds = [];
  696. roleList(query).then((response) => {
  697. this.roleList = response.data;
  698. this.roleListInit = response.data;
  699. });
  700. },
  701. showOrHidden() {
  702. if (this.form.messagType == "1") {
  703. this.isShow = true;
  704. } else {
  705. this.form.tagRoleIds = [];
  706. this.isShow = false;
  707. }
  708. },
  709. /** 下穿状态改变*/
  710. changeCheckBox() {
  711. this.getList();
  712. },
  713. },
  714. };
  715. </script>
  716. <style lang="scss" scoped>
  717. .line-style {
  718. display: -webkit-box;
  719. -webkit-line-clamp: 3; //限定显示行数
  720. -webkit-box-orient: vertical;
  721. overflow: hidden;
  722. text-overflow: ellipsis;
  723. }
  724. </style>