inform.vue 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969
  1. <template>
  2. <div class="inform">
  3. <div class="search">
  4. <el-input placeholder="请输入标题" class="search-input" clearable v-model="mixins_query.title"></el-input>
  5. <el-select placeholder="请选择所属社区" v-model="mixins_query.communityId" clearable>
  6. <el-option v-for="(item, index) in communityList" :key="index" :label="item.label" :value="item.id"></el-option>
  7. </el-select>
  8. <el-date-picker
  9. v-model="searchTime"
  10. value-format="yyyy-MM-dd"
  11. type="daterange"
  12. range-separator="至"
  13. start-placeholder="开始日期"
  14. end-placeholder="结束日期"
  15. :picker-options="pickerOptions"
  16. :editable="false"
  17. ></el-date-picker>
  18. <el-button type="primary" placeholder="状态" class="search-btn" @click="searchInfo" icon="el-icon-search">查询 </el-button>
  19. <div class="add">
  20. <img src="../../assets/img/btn_tianjia@2x.png" alt="" @click="add" />
  21. </div>
  22. </div>
  23. <div class="content">
  24. <div class="roles-wrap">
  25. <zz-table
  26. :cols="cols"
  27. :settings="{ showNumber: true, stripe: true, showNumberWidth: '100' }"
  28. :data="mixins_list"
  29. :pageset="mixins_pageset"
  30. @page-change="pageChange"
  31. :loading="mixins_onQuery"
  32. >
  33. <template slot="pubPeople" slot-scope="scope">
  34. {{ scope.row.pubPeople }}
  35. </template>
  36. <template slot-scope="scope" slot="releaseTime">
  37. <div>
  38. {{ scope.row.pubDate }}
  39. </div>
  40. </template>
  41. <template slot-scope="scope" slot="opt">
  42. <div class="opt" @click="clickDatail(scope.row)">
  43. <img src="../../assets/img/icon_biaodan@2x.png" alt="" />
  44. </div>
  45. </template>
  46. </zz-table>
  47. </div>
  48. <!-- 添加弹框 -->
  49. <div class="dialog-info">
  50. <el-dialog :visible.sync="centerDialogVisible" width="1086px" :close-on-press-escape="false" :close-on-click-modal="false">
  51. <div class="dialog">
  52. <div class="dialog-header">
  53. <i class="el-dialog__close el-icon el-icon-close" @click="dialogButton('clear')"></i>
  54. <div class="dialogTitle" v-if="showDetail">
  55. 物业通知发布(
  56. <span style="color: #ff7f7f"> *</span>
  57. 为必填项)
  58. </div>
  59. <div class="dialogTitle" v-else>{{ rowDetail.type == 0 ? '物业通知' : '社区活动' }}详情</div>
  60. </div>
  61. <div class="dialog-contents">
  62. <div class="dialog-left">
  63. <div v-if="showDetail">
  64. <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="101px" class="demo-ruleForm">
  65. <el-form-item label="所属社区" prop="popCommunityId">
  66. <el-select
  67. placeholder="请选择所属社区"
  68. v-model="ruleForm.popCommunityId"
  69. clearable
  70. class="dialog-select"
  71. @change="changeCommunity"
  72. >
  73. <el-option
  74. v-for="(item, index) in communityList"
  75. :key="index"
  76. :label="item.label"
  77. :value="item.id"
  78. ></el-option>
  79. </el-select>
  80. </el-form-item>
  81. <el-form-item label="发布对象" prop="issueRoom">
  82. <div class="issueRoom">
  83. <div class="radio-room">
  84. <el-checkbox
  85. label="社区住户"
  86. name="type"
  87. v-model="ruleForm.issueRoom.checkAll"
  88. @change="changeCheckboxRoom"
  89. ></el-checkbox>
  90. <el-radio-group
  91. v-model="ruleForm.issueRoom.radioRoom"
  92. :disabled="!ruleForm.issueRoom.checkAll"
  93. @change="changeRadioRoom"
  94. >
  95. <el-radio label="全部房间"></el-radio>
  96. <el-radio label="指定房间"></el-radio>
  97. </el-radio-group>
  98. </div>
  99. <div class="selet-room" v-show="ruleForm.issueRoom.checkAll">
  100. <tree-house
  101. :buildingType="1"
  102. :showCheckboxTree="true"
  103. :defaultExpandAllTree="false"
  104. :accordion="true"
  105. :selectAll="true"
  106. @selectData="selectDataHouseTree"
  107. :disabledHouse="disabledHouse"
  108. ref="selectTreeHouse"
  109. ></tree-house>
  110. </div>
  111. </div>
  112. <div class="issueRoom">
  113. <div class="radio-room">
  114. <el-checkbox
  115. label="物业员工"
  116. name="type"
  117. v-model="ruleForm.issueRoom.staff"
  118. @change="changeCheckboxStaffRoom"
  119. ></el-checkbox>
  120. <el-radio-group
  121. v-model="ruleForm.issueRoom.radioStaff"
  122. :disabled="!ruleForm.issueRoom.staff"
  123. @change="changeRadioStaffRoom"
  124. >
  125. <el-radio label="全部员工"></el-radio>
  126. <el-radio label="指定员工"></el-radio>
  127. </el-radio-group>
  128. </div>
  129. <div class="selet-room" v-show="ruleForm.issueRoom.staff">
  130. <tree-house
  131. ref="selectTreePeoples"
  132. :buildingType="1"
  133. :showCheckboxTree="true"
  134. :defaultExpandAllTree="false"
  135. :showHouseTree="false"
  136. :accordionPeople="true"
  137. :selectAll="true"
  138. @dataPeople="dataPeople"
  139. @selectPeople="selectPeople"
  140. :disabled="disabledPeople"
  141. ></tree-house>
  142. </div>
  143. </div>
  144. </el-form-item>
  145. <el-form-item label="通知类型" prop="informType">
  146. <el-select
  147. v-model="ruleForm.informType"
  148. @change="changeInformType"
  149. clearable
  150. class="dialog-select"
  151. placeholder="请选择通知类型"
  152. >
  153. <el-option
  154. v-for="(item, index) in informTypes"
  155. :key="index"
  156. :label="item.label"
  157. :value="item.status"
  158. >{{ item.label }}</el-option
  159. >
  160. </el-select>
  161. </el-form-item>
  162. <el-form-item label="标题" prop="title">
  163. <el-input v-model="ruleForm.title" placeholder="不能超过20字" maxlength="20"></el-input>
  164. </el-form-item>
  165. <el-form-item label="是否紧急" prop="exigencyOr">
  166. <el-radio-group v-model="ruleForm.exigencyOr" @change="changeRadioExigencyOr">
  167. <el-radio label="是"></el-radio>
  168. <el-radio label="否"></el-radio>
  169. </el-radio-group>
  170. </el-form-item>
  171. <el-form-item label="选择时间" prop="activeTime" v-if="showUploadImage">
  172. <el-date-picker
  173. v-model="ruleForm.activeTime"
  174. type="datetimerange"
  175. range-separator="至"
  176. start-placeholder="开始日期"
  177. end-placeholder="结束日期"
  178. :picker-options="pickerOptions"
  179. :editable="false"
  180. ></el-date-picker>
  181. </el-form-item>
  182. <el-form-item label="主题图片" prop="image" v-if="showUploadImage">
  183. <div class="up-image">
  184. <up-image
  185. color="#1890ff"
  186. class="editor-upload-btn"
  187. @successCBK="imageSuccessCBK"
  188. @deleteImage="deleteImage"
  189. @successImageList="successImageList"
  190. @clearImageList="clearImageList"
  191. ref="upImages"
  192. ></up-image>
  193. </div>
  194. </el-form-item>
  195. <el-form-item label="通知内容" prop="editorContents">
  196. <!-- tinymce-editor 富文本编辑器 -->
  197. <div class="editor-container">
  198. <tinymce v-model="ruleForm.editorContents" ref="endit" :height="150" />
  199. </div>
  200. </el-form-item>
  201. <el-form-item label="文件上传" prop="fill">
  202. <div>
  203. <el-upload
  204. class="upload-fill"
  205. action="/sc-community-web/upload/uploadFile"
  206. :on-preview="handlePreview"
  207. :on-remove="handleRemove"
  208. :before-remove="beforeRemove"
  209. multiple
  210. :limit="3"
  211. :on-exceed="handleExceed"
  212. :file-list="fileList"
  213. :on-success="successFile"
  214. >
  215. <el-button size="small" icon="el-icon-paperclip">选择附件</el-button>
  216. <div slot="tip" class="el-upload-text">
  217. 支持格式:.rar .zip .doc .docx .pdf ,单个文件不能超过20MB
  218. </div>
  219. </el-upload>
  220. </div>
  221. </el-form-item>
  222. <el-form-item class="dialog-footer">
  223. <span>
  224. <el-button type="primary" @click="dialogButton('clear')" plain>取消</el-button>
  225. <el-button type="primary" @click="dialogButton('prev')">发布</el-button>
  226. </span>
  227. </el-form-item>
  228. </el-form>
  229. </div>
  230. <div v-if="!showDetail">
  231. <!-- 详情显示 -->
  232. <previe-inform
  233. :dataDetail="rowDetail"
  234. :filePath="filePath"
  235. :successImageLists="successImageLists"
  236. :houseData="houseData"
  237. :peopleData="peopleData"
  238. :houseDataNames="houseDataNames"
  239. ref="filterHouse"
  240. ></previe-inform>
  241. </div>
  242. </div>
  243. <div class="dialog-right">
  244. <div class="dialog-right-top">
  245. <img src="../../assets/img/phoneHeader.png" alt="" />
  246. </div>
  247. <div class="dialog-right-header">
  248. <i class="el-icon-arrow-left"></i>
  249. <div v-if="showDetail">{{ this.showUploadImage ? '社区活动' : '物业通知' }}</div>
  250. <div v-else>{{ rowDetail.type == 0 ? '物业通知' : '社区活动' }}</div>
  251. </div>
  252. <div class="center-padding"></div>
  253. <GeminiScrollbar class="my-scroll-bar" :autoshow="true">
  254. <div class="dialog-right-content">
  255. <div class="dialog-title">
  256. <div class="dialog-titles" v-if="showDetail">
  257. {{ ruleForm.title ? ruleForm.title : '标题' }}
  258. </div>
  259. <div class="dialog-titles" v-else>
  260. {{ rowDetail.title ? rowDetail.title : '标题' }}
  261. </div>
  262. <div v-if="showDetail">
  263. <div class="dialog-urgency" v-if="ruleForm.exigencyOr == '是'">紧急</div>
  264. </div>
  265. <div v-else>
  266. <div class="dialog-urgency" v-if="rowDetail.urgentFlag">紧急</div>
  267. </div>
  268. <!-- ruleForm.exigencyOr -->
  269. </div>
  270. <div class="dialog-right-time" v-if="!showDetail">{{ rowDetail.pubDate }}</div>
  271. <div class="dialog-right-time" v-else>{{ new Date() | filterTime }}</div>
  272. <div></div>
  273. <div class="content">
  274. <div class="content-text" v-if="showDetail">
  275. <div v-html="ruleForm.editorContents" id="content" />
  276. </div>
  277. <div class="content-text" v-else>
  278. <div v-html="contentHtml" id="content" />
  279. </div>
  280. <div class="content-inform">
  281. <!-- <div>{{ !showDetail ? rowDetail.communityName : popCommunityName }}</div>
  282. <div v-if="rowDetail">{{ rowDetail.pubDate }}</div>
  283. <div v-else>{{ new Date() | filterTime }}</div>
  284. <div>物业电话:{{ $store.state.cruUserInfo.phone }}</div> -->
  285. </div>
  286. <div v-if="showDetail">
  287. <div class="file-name" v-for="(item, index) of uploadFileUrl" :key="index">
  288. <span class="file-name-left"><i class="el-icon-paperclip"></i> </span>
  289. <span class="file-name-right">
  290. {{ item.name }}
  291. </span>
  292. </div>
  293. </div>
  294. <div v-else>
  295. <div class="file-name" v-for="(item, index) of filePath" :key="index">
  296. <span class="file-name-left"><i class="el-icon-paperclip"></i> </span>
  297. <span class="file-name-right">
  298. {{ item.name }}
  299. </span>
  300. </div>
  301. </div>
  302. </div>
  303. <div></div>
  304. </div>
  305. </GeminiScrollbar>
  306. </div>
  307. </div>
  308. </div>
  309. </el-dialog>
  310. </div>
  311. </div>
  312. </div>
  313. </template>
  314. <script>
  315. import list from '@utils/list.js';
  316. import previeInform from './common/previeInform';
  317. import upImage from './common/upImage';
  318. // Tinymce 富文本编辑器
  319. import Tinymce from '@/components/Tinymce';
  320. const content = '';
  321. export default {
  322. mixins: [list],
  323. components: { previeInform, Tinymce, upImage },
  324. data() {
  325. let _this = this;
  326. return {
  327. disabledHouse: true,
  328. disabledPeople: true,
  329. organList: [],
  330. popCommunityName: '',
  331. fileList: [],
  332. // 显示图片上传
  333. showUploadImage: false,
  334. dialogImageUrl: '',
  335. // 显示详情
  336. showDetail: true,
  337. rowDetail: '',
  338. contentHtml: '',
  339. // 查询的时间
  340. searchTime: [],
  341. // 添加弹框信息
  342. ruleForm: {
  343. popCommunityId: '', //所属社区
  344. //发布对象
  345. issueRoom: {
  346. checkAll: false,
  347. radioRoom: '',
  348. staff: false,
  349. radioStaff: ''
  350. },
  351. disabledRoom: false, //单选框是否禁用
  352. disabledStaffRoom: false,
  353. informType: '', //通知类型
  354. title: '', //标题
  355. exigencyOr: '是', //是否紧急
  356. exigencyText: true,
  357. activeTime: [],
  358. editorContents: '',
  359. // informContent: content, //通知内容
  360. informContent: '', //通知内容
  361. upload: '' // 文件上传
  362. },
  363. rules: {
  364. popCommunityId: [{ required: true, message: '请选择社区', trigger: 'change' }],
  365. radioRoom: [{ required: true, message: '请选择房间', trigger: 'change' }],
  366. informType: [{ required: true, message: '请选择通知类型', trigger: 'change' }],
  367. title: [{ required: true, message: '请输入标题', trigger: 'blur' }],
  368. exigencyOr: [{ required: true, message: '请选择是否紧急', trigger: 'change' }],
  369. activeTime: [{ required: true, message: '请选择时间', trigger: 'change' }],
  370. issueRoom: [{ required: true, message: '请选择发布对象', trigger: 'change' }],
  371. editorContents: [{ required: true, message: '请发布内容', trigger: 'blur' }] //通知内容
  372. },
  373. // 输入地址
  374. location: '',
  375. // 通知类型
  376. informTypes: [
  377. {
  378. status: 0,
  379. label: '物业通知'
  380. },
  381. {
  382. status: 1,
  383. label: '社区活动'
  384. }
  385. ],
  386. cols: [
  387. {
  388. label: '标题',
  389. prop: 'title'
  390. },
  391. {
  392. label: '所属社区',
  393. prop: 'communityName'
  394. },
  395. {
  396. label: '通知类型',
  397. prop: 'type',
  398. format(val) {
  399. if (val == 0) {
  400. return '物业通知';
  401. } else if (val == 1) {
  402. return '社区活动';
  403. } else {
  404. return '其他';
  405. }
  406. }
  407. },
  408. {
  409. label: '是否紧急',
  410. prop: 'urgentFlag',
  411. format(val) {
  412. if (val == 0) {
  413. return '不紧急';
  414. } else if (val == 1) {
  415. return '紧急';
  416. } else {
  417. return '---';
  418. }
  419. }
  420. },
  421. {
  422. label: '发布时间',
  423. prop: 'pubDate',
  424. slot: 'releaseTime'
  425. },
  426. {
  427. label: '状态',
  428. prop: 'status',
  429. format(val) {
  430. return val ? val : '已发布';
  431. }
  432. },
  433. {
  434. label: '发布人',
  435. prop: 'pubPeople',
  436. slot: 'pubPeople'
  437. },
  438. {
  439. label: '操作',
  440. prop: 'id',
  441. slot: 'opt'
  442. }
  443. ],
  444. mixins_post: 'post',
  445. // 显隐弹框
  446. centerDialogVisible: false,
  447. // 获取的房间信息
  448. houseData: [],
  449. houseDataNames: '',
  450. peopleData: [],
  451. // 选中的房间
  452. selectDataHouseTreeData: {
  453. checkData: [],
  454. userID: [],
  455. userList: []
  456. },
  457. houseNames: [],
  458. PeopleNames: [],
  459. // 选中的人员
  460. selectDataPeopleTreeData: {
  461. checkData: [],
  462. userList: []
  463. },
  464. // 文件上传地址
  465. uploadFileUrl: []
  466. };
  467. },
  468. created() {
  469. this.getCommunityList();
  470. this.mixins_post;
  471. this.mixins_dataUrl = '/sc-community-web/notice/page';
  472. this.mixins_query = {};
  473. this.mixins_search();
  474. this.getOrgTreeList();
  475. // 显示弹框
  476. // this.getPeople();
  477. if (this.$route.query.showDialog && this.$route.query.id && !this.$route.query.closeDialog) {
  478. let row = {
  479. id: this.$route.query.id
  480. };
  481. this.clickDatail(row);
  482. }
  483. },
  484. mounted() {},
  485. watch: {},
  486. methods: {
  487. // 人员树
  488. // dataPeople(data) {
  489. // this.peopleData = data;
  490. // },
  491. // 上传文件
  492. handleRemove(file, fileList) {
  493. console.log('上传文件', file, fileList);
  494. },
  495. handlePreview(file) {
  496. console.log('点击文件', file);
  497. },
  498. successFile(file, fileLists) {
  499. console.log('上传文件successFile', fileLists);
  500. let obj = {};
  501. // this.fileList.push(fileLists.name);
  502. let resName = fileLists.response.data;
  503. obj.oldName = resName;
  504. obj.name = fileLists.name;
  505. // this.uploadFileUrl= this.uploadFileUrl.concat(newName + ',');
  506. this.uploadFileUrl.push(obj);
  507. },
  508. handleExceed(files, fileList) {
  509. this.$message.warning(
  510. `当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`
  511. );
  512. },
  513. beforeRemove(file, fileList) {
  514. let removeName = this.fileList.filter((item) => {
  515. return item.name != file.name;
  516. });
  517. this.fileList = removeName;
  518. this.uploadFileUrl = removeName;
  519. console.log('点击移除', this.fileList);
  520. },
  521. /**上传图片*/
  522. successImageList(arr) {
  523. this.successImageLists = arr;
  524. console.log('====================================');
  525. console.log('上传图片', arr);
  526. console.log('====================================');
  527. },
  528. imageSuccessCBK(arr) {
  529. this.$refs.endit.imageSuccessCBK(arr);
  530. },
  531. deleteImage(val) {
  532. this.$refs.endit.deleteImage(val);
  533. },
  534. handleRemove(file) {
  535. console.log(file);
  536. },
  537. handleDownload(file) {
  538. console.log(file);
  539. },
  540. // 添加弹框下拉框变化
  541. changeCommunity(val) {
  542. console.log('添加弹框下拉框变化', val);
  543. this.$http
  544. .get('/sc-community/assets/tree/community/find', { buildingType: this.buildingType })
  545. .then(({ status, data, msg }) => {
  546. if (status === 0 && data) {
  547. this.$refs.selectTreeHouse.filterhouse(val, data);
  548. this.ruleForm.issueRoom.checkAll = true;
  549. this.ruleForm.issueRoom.radioRoom = '全部房间';
  550. this.ruleForm.issueRoom.radioStaff = '';
  551. this.ruleForm.issueRoom.staff = false;
  552. } else {
  553. this.$message.warning('获取房间失败');
  554. }
  555. });
  556. },
  557. // 选中的房间
  558. selectDataHouseTree(val) {
  559. this.selectDataHouseTreeData.userID = [];
  560. this.selectDataHouseTreeData.userID = val.userList;
  561. // this.selectDataHouseTreeData = val;
  562. // 获取房间下的usid
  563. this.$http.post('/sc-community-web/notice/queryHouseUser', val.userList).then((res) => {
  564. if (res.status === 0) {
  565. this.selectDataHouseTreeData.userList = res.data;
  566. } else {
  567. // this.$message('获取房间失败');
  568. }
  569. });
  570. console.log('选中的房间val', val);
  571. },
  572. // 选择的人员
  573. selectPeople(val) {
  574. this.selectDataPeopleTreeData = val;
  575. console.log('选择的人员inform', val);
  576. },
  577. /**监听指定房间单选框变化*/
  578. changeRadioRoom(val) {
  579. if (!this.ruleForm.popCommunityId) {
  580. return this.$message.warning('请先选择所属社区');
  581. }
  582. if (val == '指定房间') {
  583. this.ruleForm.disabledRoom = true;
  584. this.$refs.selectTreeHouse.selectHouseOr();
  585. } else {
  586. this.ruleForm.disabledRoom = false;
  587. this.$refs.selectTreeHouse.selectAllHouse();
  588. }
  589. console.log('监听房间单选框变化', val);
  590. },
  591. //选择员工复选框变化
  592. changeCheckboxStaffRoom(val) {
  593. if (!this.ruleForm.popCommunityId) {
  594. this.ruleForm.issueRoom.staff = false;
  595. return this.$message.warning('请先选择社区');
  596. }
  597. if (val) {
  598. this.ruleForm.issueRoom.radioStaff = '全部员工';
  599. this.ruleForm.issueRoom.checkAll = false;
  600. this.ruleForm.issueRoom.radioRoom = '';
  601. this.$refs.selectTreePeoples.selectAllPeople();
  602. this.$refs.selectTreeHouse.selectHouseOr();
  603. } else {
  604. this.ruleForm.issueRoom.radioStaff = '';
  605. this.ruleForm.issueRoom.checkAll = true;
  606. this.ruleForm.issueRoom.radioRoom = '全部房间';
  607. this.$refs.selectTreePeoples.selectPeopleOr();
  608. this.$refs.selectTreeHouse.selectAllHouse();
  609. }
  610. },
  611. // 选择房间复选框变化
  612. changeCheckboxRoom(val) {
  613. if (!this.ruleForm.popCommunityId) {
  614. this.ruleForm.issueRoom.checkAll = false;
  615. return this.$message.warning('请先选择社区');
  616. }
  617. if (val) {
  618. this.ruleForm.issueRoom.staff = false;
  619. this.ruleForm.issueRoom.checkAll = true;
  620. this.ruleForm.issueRoom.radioRoom = '全部房间';
  621. this.ruleForm.issueRoom.radioStaff = '';
  622. this.$refs.selectTreeHouse.selectAllHouse();
  623. } else {
  624. this.ruleForm.issueRoom.radioRoom = '';
  625. this.$refs.selectTreeHouse.selectHouseOr();
  626. }
  627. },
  628. // 指定员工
  629. changeRadioStaffRoom(val) {
  630. if (val == '指定员工') {
  631. this.ruleForm.disabledStaffRoom = true;
  632. this.$refs.selectTreePeoples.selectPeopleOr();
  633. } else {
  634. this.ruleForm.disabledStaffRoom = false;
  635. this.$refs.selectTreePeoples.selectAllPeople();
  636. }
  637. },
  638. // 是否紧急
  639. changeRadioExigencyOr(val) {
  640. if (val == '否') {
  641. this.ruleForm.exigencyText = false;
  642. } else {
  643. this.ruleForm.exigencyText = true;
  644. }
  645. },
  646. // 发布活动类型
  647. changeInformType(val) {
  648. this.successImageLists = '';
  649. if (val) {
  650. this.showUploadImage = true;
  651. } else {
  652. this.showUploadImage = false;
  653. }
  654. this.rowDetail = '';
  655. this.showDetail = true;
  656. this.centerDialogVisible = true;
  657. this.$refs.upImages.clearImageList('');
  658. this.$refs.endit.setContent('');
  659. console.log('发布活动类型', val);
  660. },
  661. // 清空
  662. clear() {
  663. this.rowDetail = '';
  664. this.showUploadImage = false;
  665. this.ruleForm.issueRoom.staff = false;
  666. this.ruleForm.issueRoom.checkAll = false;
  667. // this.showDetail = false;
  668. this.filePath = '';
  669. this.uploadFileUrl = [];
  670. this.fileList = [];
  671. this.ruleForm.exigencyText = true;
  672. this.contentHtml = '';
  673. this.setContent = '';
  674. this.$refs.endit.setContent('');
  675. this.$refs['ruleForm'].resetFields();
  676. },
  677. /**添加按钮 */
  678. add() {
  679. this.centerDialogVisible = true;
  680. this.showDetail = true;
  681. this.rowDetail = '';
  682. this.showUploadImage = false;
  683. this.ruleForm.issueRoom.checkAll = false;
  684. this.ruleForm.issueRoom.radioRoom = '';
  685. this.ruleForm.issueRoom.staff = false;
  686. this.ruleForm.issueRoom.radioStaff = '';
  687. this.filePath = '';
  688. this.uploadFileUrl = [];
  689. this.fileList = [];
  690. this.$refs.endit.setContent('');
  691. this.$refs['ruleForm'].resetFields();
  692. if (this.showUploadImage) {
  693. this.$refs.upImages.clearImageList('');
  694. }
  695. },
  696. /**查询按钮*/
  697. searchInfo() {
  698. let detaH = this.$moment(new Date()).format('HH');
  699. let detaM = this.$moment(new Date()).format('mm');
  700. let detaS = this.$moment(new Date()).format('ss');
  701. // let d = detaH + ':' + detaM + ':' + detaS;
  702. let d = '00:00:00';
  703. let dEnd = '23:59:59';
  704. if (this.searchTime && this.searchTime.length) {
  705. this.mixins_query.startTime = `${this.searchTime[0]}T${d}`;
  706. this.mixins_query.endTime = `${this.searchTime[1]}T${dEnd}`;
  707. } else {
  708. this.mixins_query.startTime = this.$moment(new Date()).subtract(1, 'months').format('YYYY-MM-DDTHH:mm:ss');
  709. this.mixins_query.endTime = this.$moment(new Date()).format('YYYY-MM-DDTHH:mm:ss');
  710. }
  711. console.log('点击查询', this.searchTime);
  712. this.mixins_search();
  713. },
  714. /**
  715. * 弹框按钮
  716. * @param type 类型
  717. * @return {void}
  718. * */
  719. dialogButton(type) {
  720. if (type === 'prev') {
  721. this.$refs['ruleForm'].validate((valid) => {
  722. if (valid) {
  723. let content = this.ruleForm.editorContents;
  724. let img = [];
  725. content.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/g, function (match, capture) {
  726. img.push(capture);
  727. });
  728. if (img.length >= 3) {
  729. return this.$message.warning('最多插入三张图片');
  730. }
  731. if (
  732. this.selectDataHouseTreeData.userList.length === 0 &&
  733. this.selectDataPeopleTreeData &&
  734. this.selectDataPeopleTreeData.userList.length === 0
  735. ) {
  736. return this.$message.warning('所选房间暂无住户,不可发布');
  737. }
  738. // this.showDetail = false;
  739. let startTime = this.$moment(this.ruleForm.activeTime[0]).format(`YYYY-MM-DDTHH:mm:ss`);
  740. let endTime = this.$moment(this.ruleForm.activeTime[1]).format(`YYYY-MM-DDTHH:mm:ss`);
  741. let query = {
  742. communityId: this.ruleForm.popCommunityId,
  743. content: this.ruleForm.editorContents,
  744. startTime: this.showUploadImage ? startTime : '',
  745. endTime: this.showUploadImage ? endTime : '',
  746. filePath: JSON.stringify(this.uploadFileUrl),
  747. id: 1,
  748. pubDate: this.$moment(new Date()).format(`YYYY-MM-DDTHH:mm:ss`),
  749. // pubPeople:ruleForm.informType,
  750. // pubStatus: "",
  751. themePictrue: JSON.stringify(this.successImageLists),
  752. userId: this.ruleForm.issueRoom.checkAll
  753. ? this.selectDataHouseTreeData.userList
  754. : this.selectDataPeopleTreeData.userList,
  755. treeData: this.ruleForm.issueRoom.checkAll
  756. ? JSON.stringify(this.selectDataHouseTreeData.userID)
  757. : JSON.stringify(this.selectDataPeopleTreeData.userList),
  758. title: this.ruleForm.title,
  759. type: this.ruleForm.informType,
  760. urgentFlag: this.ruleForm.exigencyOr == '是' ? 1 : 0,
  761. userType: this.ruleForm.issueRoom.checkAll ? 0 : 1
  762. };
  763. this.$http.post('/sc-community-web/notice/add', query).then((res) => {
  764. if (res.status === 0) {
  765. this.$message.success('发布成功');
  766. this.$refs.endit.setContent('');
  767. this.$refs['ruleForm'].resetFields();
  768. this.successImageList = [];
  769. this.clear();
  770. this.$refs['ruleForm'].resetFields();
  771. if (this.showUploadImage) {
  772. this.$refs.upImages.clearImageList('');
  773. }
  774. this.mixins_search();
  775. } else {
  776. this.$message('发布失败,请稍后重试');
  777. this.successImageList = [];
  778. this.contentHtml = '';
  779. this.clear();
  780. }
  781. this.centerDialogVisible = false;
  782. console.log('点击发布', res);
  783. });
  784. } else {
  785. return false;
  786. }
  787. });
  788. } else if (type == 'clear') {
  789. if (this.$route.query.showDialog) {
  790. this.$router.replace('/workbench/index');
  791. }
  792. this.centerDialogVisible = false;
  793. this.clear();
  794. this.$refs['ruleForm'].resetFields();
  795. if (this.showUploadImage) {
  796. this.$refs.upImages.clearImageList('');
  797. }
  798. } else {
  799. this.centerDialogVisible = false;
  800. this.clear();
  801. this.$refs['ruleForm'].resetFields();
  802. if (this.showUploadImage) {
  803. this.$refs.upImages.clearImageList('');
  804. }
  805. }
  806. },
  807. /** 获取社区列表*/
  808. getCommunityList() {
  809. this.communityList = [];
  810. var onOption = '';
  811. this.$http.get('/sc-community/assets/community/list', {}).then((res) => {
  812. // this.$store.commit('setAreaSelect', res.data);
  813. console.log('获取社区列表', res);
  814. res.data.map((res) => {
  815. onOption = {
  816. label: res.communityName,
  817. id: res.id
  818. };
  819. this.communityList.push(onOption);
  820. });
  821. });
  822. },
  823. filterPeople(arr) {
  824. arr.map((item, index) => {
  825. if (item.children && item.children.length > 0) {
  826. this.filterPeople(item.children);
  827. } else if (item.children == null) {
  828. this.filterArrPeople(arr, item, index);
  829. }
  830. });
  831. },
  832. filterArrPeople(arr, item, index) {
  833. if (!this.rowDetail.treeData.includes(Number(item.id))) {
  834. arr.splice(index, 1);
  835. arr.map((item) => {
  836. this.filterArrPeople(arr, item, index);
  837. });
  838. }
  839. },
  840. filterPeopleName(array) {
  841. console.log('====================================');
  842. console.log(' filterPeopleName(array', array);
  843. console.log('====================================');
  844. var that = this;
  845. // array.map((item) => {
  846. // if (item.children && item.children.length > 0) {
  847. // that.filterName(item.children);
  848. // that.houseNames.push(item.name);
  849. // } else if (item.type == 'room') {
  850. // that.houseNames.push(item.name);
  851. // }
  852. // });
  853. array.map((item) => {
  854. if (item.children) {
  855. that.filterPeopleName(item.children);
  856. } else if (item.children == null) {
  857. that.PeopleNames.push(item.value);
  858. }
  859. });
  860. },
  861. // 获取人员
  862. getPeopleList() {
  863. this.PeopleNames = [];
  864. this.$http.get('/sc-user-center/user/findUserList').then(({ status, data, msg }) => {
  865. if (status === 0) {
  866. this.peopleData = data;
  867. this.filterPeople(this.peopleData);
  868. this.filterPeopleName(this.peopleData);
  869. this.houseDataNames = this.PeopleNames.toString();
  870. } else {
  871. this.$message(warning, '获取人员失败,请稍后重试');
  872. }
  873. });
  874. },
  875. dimension(arr) {
  876. arr.map((item, index) => {
  877. if (item.children) {
  878. this.dimension(item.children);
  879. } else if (item.type == 'room') {
  880. this.filterArr(arr, item, index);
  881. }
  882. });
  883. },
  884. filterArr(arr, item, index) {
  885. if (!this.rowDetail.treeData.includes(Number(item.value))) {
  886. arr.splice(index, 1);
  887. arr.map((item) => {
  888. this.filterArr(arr, item, index);
  889. });
  890. }
  891. },
  892. filterName(array) {
  893. var that = this;
  894. array.map((item) => {
  895. if (item.children && item.children.length > 0) {
  896. that.houseNames.push(item.name);
  897. that.filterName(item.children);
  898. } else if (item.type == 'room') {
  899. that.houseNames.push(item.name);
  900. }
  901. });
  902. },
  903. // 获取房间
  904. getOrgTreeList() {
  905. this.houseNames = [];
  906. this.$http
  907. .get('/sc-community/assets/tree/community/find', { buildingType: this.buildingType })
  908. .then(({ status, data, msg }) => {
  909. if (status === 0 && data) {
  910. var arr = data.filter((item) => {
  911. return item.id == this.rowDetail.communityId;
  912. });
  913. this.houseData = arr;
  914. this.dimension(this.houseData);
  915. this.filterName(this.houseData);
  916. let h = [...new Set(this.houseNames)];
  917. this.houseDataNames = this.houseNames.toString();
  918. }
  919. });
  920. },
  921. /** 查看详情*/
  922. clickDatail(row) {
  923. // this.rowDetail = [];
  924. this.$http.get('/sc-community-web/notice/find/' + row.id).then((res) => {
  925. if (res.status === 0) {
  926. this.rowDetail = res.data;
  927. this.rowDetail.treeData = JSON.parse(res.data.treeData);
  928. // this.rowDetail.newName = this.houseNames.toString();
  929. if (res.data.userType == 0) {
  930. this.getOrgTreeList();
  931. } else {
  932. this.getPeopleList();
  933. }
  934. // let fileArr = row.filePath.split(',');
  935. // this.filePath = fileArr.slice(0, fileArr.length - 1);
  936. this.filePath = JSON.parse(res.data.filePath);
  937. this.successImageLists = JSON.parse(res.data.themePictrue);
  938. this.contentHtml = res.data.content;
  939. this.centerDialogVisible = true;
  940. this.showDetail = false;
  941. } else {
  942. return this.$message('获取详情失败!请稍后重试');
  943. }
  944. });
  945. }
  946. }
  947. };
  948. </script>
  949. <style lang="scss" scoped>
  950. @import './style.scss';
  951. /deep/ .html-left {
  952. width: 16%;
  953. }
  954. </style>