index.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736
  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. v-model="form.tagOrgIds"
  324. :queryData="parseInt(form.tagOrgType)"
  325. ref="orgTreeSelect"
  326. :enabledCheckOrgTypes="parseInt(form.tagOrgType)"
  327. :disable="true"
  328. :disabled="!isSubmit"
  329. @selectNode="selectNodeId"
  330. >
  331. </org-tree-select>
  332. </el-form-item>
  333. <!-- </el-form-item>-->
  334. <el-form-item label="目标角色" v-if="isShow" prop="tagRoleIds"
  335. :rules="{required: isShow?true:false, message: '请选择目标角色', trigger: 'blur'}">
  336. <el-select
  337. v-model="form.tagRoleIds"
  338. placeholder="请选择目标角色"
  339. :disabled="!isSubmit"
  340. multiple
  341. >
  342. <el-option
  343. v-for="item in roleList"
  344. :key="item.id"
  345. :label="item.name"
  346. :value="item.id"
  347. ></el-option>
  348. </el-select>
  349. </el-form-item>
  350. <el-form-item label="内容" prop="content">
  351. <el-input
  352. v-model="form.content"
  353. type="textarea"
  354. placeholder="请输入内容"
  355. :disabled="!isSubmit"
  356. :autosize="{ minRows: 6, maxRows: 10 }"
  357. :maxlength="2000"
  358. show-word-limit
  359. />
  360. </el-form-item>
  361. <el-form-item label="附件" prop="fileList">
  362. <K-file-upload
  363. ref="upload"
  364. :defaultValue="formFileListDefualtValue"
  365. :disabled="!isSubmit"
  366. :isShowUploadBtn="!isSubmit ? false : true"
  367. v-model="form.fileList"
  368. />
  369. </el-form-item>
  370. </el-form>
  371. <div slot="footer" class="dialog-footer">
  372. <el-button type="primary" v-if="isSubmit" @click="submitForm"
  373. >确 定
  374. </el-button
  375. >
  376. <el-button @click="cancel" v-if="isSubmit">取 消</el-button>
  377. <el-button @click="cancel" v-else>关 闭</el-button>
  378. </div>
  379. </DialogCom>
  380. </div>
  381. </template>
  382. <script>
  383. import {
  384. listNotification,
  385. getNotification,
  386. delNotification,
  387. addNotification,
  388. updateNotification,
  389. roleList,
  390. publishNotification,
  391. } from "@/api/core/notification";
  392. // import OrgTree from "@/components/orgTree";
  393. import OrgTree from "@/components/orgTree/orgQuerySelector.vue";
  394. import KFileUpload from "@/components/K-FileUpload/index.vue";
  395. import OrgTreeSelect from "@/components/orgTreeSelect";
  396. import {mapGetters} from "vuex";
  397. export default {
  398. components: {OrgTree, KFileUpload, OrgTreeSelect},
  399. name: "Notification",
  400. dicts: ["messag_type", "message_status", "sys_org_type"],
  401. data() {
  402. return {
  403. // 遮罩层
  404. loading: true,
  405. // 选中数组
  406. ids: [],
  407. // 非单个停用
  408. single: true,
  409. // 非多个停用
  410. multiple: true,
  411. // 显示搜索条件
  412. showSearch: true,
  413. // 总条数
  414. total: 0,
  415. // 公告通知表格数据
  416. notificationList: [],
  417. // 弹出层标题
  418. title: "",
  419. // 是否显示弹出层
  420. open: false,
  421. orgId: null,
  422. loginOrgId: null,
  423. // 查询参数
  424. queryParams: {
  425. pageNum: 1,
  426. pageSize: 10,
  427. title: null,
  428. dateRange: [],
  429. messagStatus: null,
  430. checkSub: true,
  431. },
  432. isShow: false,
  433. isSubmit: true,
  434. roleList: [],
  435. roleListInit: [],
  436. formFileListDefualtValue: [],
  437. // 表单参数
  438. form: {
  439. title: null,
  440. messagType: null,
  441. tagOrgType: null,
  442. tagOrgIds: [],
  443. content: null
  444. },
  445. // 表单校验
  446. rules: {
  447. title: [{required: true, message: "请输入标题"}],
  448. messagType: [{required: true, message: "请选择消息类型"}],
  449. tagOrgType: [{required: true, message: "请选择机构类型"}],
  450. tagOrgIds: [{required: true, message: "请选择目标机构", trigger: 'change'}],
  451. content: [{required: true, message: "请输入内容"}],
  452. },
  453. };
  454. },
  455. computed: {
  456. ...mapGetters(["orgId"]),
  457. },
  458. created() {
  459. this.orgId = this.$store.getters.orgId;
  460. this.loginOrgId = this.$store.getters.orgId;
  461. this.queryParams.orgId = this.$store.getters.orgId;
  462. this.getList();
  463. this.initRoleList();
  464. },
  465. methods: {
  466. selectNodeId(val){
  467. this.form.tagOrgIds=val.map(item=>item.id)
  468. this.$refs.form.validateField('tagOrgIds',(errorMessage)=>{
  469. console.log(errorMessage,'errorMessage')
  470. if(!errorMessage){
  471. }else{
  472. return false
  473. }
  474. })
  475. },
  476. /** 查询公告通知列表 */
  477. getList() {
  478. this.loading = true;
  479. listNotification(this.queryParams).then((response) => {
  480. this.notificationList = response.rows;
  481. this.total = response.total;
  482. this.loading = false;
  483. });
  484. },
  485. getRolename(roleIds) {
  486. if (roleIds != null && roleIds.length > 0) {
  487. return roleIds
  488. .map((v) => {
  489. if (this.roleListInit.find((item) => item.id === v)) {
  490. return this.roleListInit.find((item) => item.id === v).name;
  491. } else {
  492. return "";
  493. }
  494. })
  495. .join(",");
  496. } else {
  497. return "";
  498. }
  499. },
  500. // 取消按钮
  501. cancel() {
  502. this.open = false;
  503. this.$refs.orgTreeSelect.clear();
  504. //this.roleList=[];
  505. this.reset();
  506. this.isSubmit = true;
  507. this.isShow = false;
  508. },
  509. handleClose() {
  510. this.cancel();
  511. },
  512. queryNode(nodes) {
  513. this.form.tagOrgIds = JSON.parse(nodes).map((v) => {
  514. return v.id;
  515. });
  516. },
  517. // 表单重置
  518. reset() {
  519. this.form = {
  520. id: null,
  521. orgId: null,
  522. orgName: null,
  523. orgPath: null,
  524. title: null,
  525. content: null,
  526. messagType: null,
  527. tagOrgIds: [],
  528. tagRoleIds: null,
  529. createBy: null,
  530. createTime: null,
  531. publishTime: null,
  532. messagStatus: null,
  533. fileList: [],
  534. };
  535. this.resetForm("form");
  536. },
  537. /** 搜索按钮操作 */
  538. handleQuery() {
  539. this.queryParams.pageNum = 1;
  540. this.getList();
  541. },
  542. /** 重置按钮操作 */
  543. resetQuery() {
  544. this.resetForm("queryForm");
  545. this.queryParams.orgId = this.$store.getters.orgId;
  546. this.queryParams.checkSub = true;
  547. this.$refs["orgTree"].setCheckSub(this.queryParams.checkSub)
  548. this.queryParams.dateRange = [];
  549. this.handleQuery();
  550. },
  551. // 多选框选中数据
  552. handleSelectionChange(selection) {
  553. this.ids = selection.map((item) => item.id);
  554. this.single = selection.length !== 1;
  555. this.multiple = !selection.length;
  556. },
  557. /** 新增按钮操作 */
  558. handleAdd() {
  559. this.reset();
  560. this.initRoleList();
  561. this.formFileListDefualtValue = [];
  562. this.open = true;
  563. this.isShow = false;
  564. this.title = "添加公告通知";
  565. },
  566. /** 修改按钮操作 */
  567. handleUpdate(row) {
  568. this.reset();
  569. const id = row.id || this.ids;
  570. getNotification(id).then((response) => {
  571. this.form = response.data;
  572. /* if(this.form.tagRoleIds!=null&&this.form.tagRoleIds.length>0){
  573. this.isShow=true;
  574. }*/
  575. if (this.form.messagType == 1) {
  576. this.isShow = true;
  577. }
  578. roleList(this.form.tagOrgType).then((res) => {
  579. this.roleList = res.data;
  580. });
  581. this.formFileListDefualtValue = this.form.fileList;
  582. this.open = true;
  583. this.title = "编辑公告通知";
  584. });
  585. },
  586. lookThisOne(row) {
  587. this.reset();
  588. this.isSubmit = false;
  589. const id = row.id || this.ids;
  590. getNotification(id).then((response) => {
  591. this.form = response.data;
  592. if (this.form.messagType == 1) {
  593. this.isShow = true;
  594. }
  595. /* if(this.form.tagRoleIds!=null&&this.form.tagRoleIds.length>0){
  596. this.isShow=true;
  597. }*/
  598. roleList(this.form.tagOrgType).then((res) => {
  599. this.roleList = res.data;
  600. });
  601. this.formFileListDefualtValue = this.form.fileList;
  602. this.open = true;
  603. this.title = "公告通知详情";
  604. });
  605. },
  606. /** 提交按钮 */
  607. submitForm() {
  608. this.form.orgId = this.orgId;
  609. this.$refs["form"].validate((valid) => {
  610. if (valid) {
  611. if (this.form.id != null) {
  612. updateNotification(this.form).then((response) => {
  613. this.$modal.msgSuccess("修改成功");
  614. this.open = false;
  615. this.$refs.orgTreeSelect.clear();
  616. this.reset();
  617. this.$refs["upload"].clearFiles();
  618. this.form.fileList = [];
  619. this.getList();
  620. });
  621. } else {
  622. addNotification(this.form).then((response) => {
  623. this.$modal.msgSuccess("新增成功");
  624. this.open = false;
  625. this.$refs.orgTreeSelect.clear();
  626. this.reset();
  627. this.form.fileList = [];
  628. this.$refs["upload"].clearFiles();
  629. this.getList();
  630. });
  631. }
  632. }
  633. });
  634. },
  635. /** 删除按钮操作 */
  636. handleDelete(row) {
  637. const ids = row.id || this.ids;
  638. this.$modal
  639. .confirm("是否确认删除该公告通知?")
  640. .then(function () {
  641. return delNotification(ids);
  642. })
  643. .then(() => {
  644. this.getList();
  645. this.$modal.msgSuccess("删除成功");
  646. })
  647. .catch(() => {
  648. });
  649. },
  650. publish(row) {
  651. const id = row.id;
  652. const messagStatus = row.messagStatus;
  653. let message = "";
  654. let returnMessage = "";
  655. if (messagStatus == 0) {
  656. message = "你确定要发布该消息吗?";
  657. returnMessage = "发布成功";
  658. } else {
  659. message = "你确定要取消发布该消息吗?";
  660. returnMessage = "取消发布成功";
  661. }
  662. this.$modal
  663. .confirm(message)
  664. .then(function () {
  665. return publishNotification(id);
  666. })
  667. .then(() => {
  668. this.getList();
  669. this.$modal.msgSuccess(returnMessage);
  670. })
  671. .catch(() => {
  672. });
  673. },
  674. getDefaultKey(key) {
  675. this.queryParams.orgId = key;
  676. this.getList();
  677. },
  678. checkChange(state) {
  679. this.queryParams.checkSub = state;
  680. this.handleQuery();
  681. },
  682. // 节点单击事件
  683. clickTreeNode(data) {
  684. this.queryParams.orgId = data.id;
  685. this.orgName = data.name;
  686. this.handleQuery();
  687. },
  688. execOrgTypeChanged(row) {
  689. this.form.tagRoleIds = [];
  690. this.$refs.orgTreeSelect.clear();
  691. this.initRoleList(this.form.tagOrgType);
  692. },
  693. initRoleList(query) {
  694. this.form.tagRoleIds = [];
  695. roleList(query).then((response) => {
  696. this.roleList = response.data;
  697. this.roleListInit = response.data;
  698. });
  699. },
  700. showOrHidden() {
  701. if (this.form.messagType == "1") {
  702. this.isShow = true;
  703. } else {
  704. this.form.tagRoleIds = [];
  705. this.isShow = false;
  706. }
  707. },
  708. /** 下穿状态改变*/
  709. changeCheckBox() {
  710. this.getList();
  711. },
  712. },
  713. };
  714. </script>
  715. <style lang="scss" scoped>
  716. .line-style {
  717. display: -webkit-box;
  718. -webkit-line-clamp: 3; //限定显示行数
  719. -webkit-box-orient: vertical;
  720. overflow: hidden;
  721. text-overflow: ellipsis;
  722. }
  723. </style>