index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <view class="uni-container-bg uni-container ">
  3. <view class="padding-tb-sm" style="">
  4. <uni-row class="demo-uni-row " :gutter="20" width="100%">
  5. <uni-col :span="24">
  6. <view class="u-page__tag-item">
  7. <u-search v-model="keyword" :show-action="true" @custom="handleQuery"></u-search>
  8. </view>
  9. </uni-col>
  10. </uni-row>
  11. </view>
  12. <view class="" v-if="tableData.length>0 && isLoaded">
  13. <uni-card v-for="(item, index) in tableData" :key="index">
  14. <view class="titles">{{item.remind_title}}</view>
  15. <view style="float: left" v-if="item.remind_content">重要提醒内容:</view>
  16. <!-- <text class="conts">{{item.taskContent}}</text> -->
  17. <rich-text :nodes="item.remind_content?item.remind_content:''" class="font-12"></rich-text>
  18. <view style="float: left;">发布日期:{{item.pubDate}}</view>
  19. <view class="an-niu">
  20. <view class="an-niu-street" @click.native="uploadButton(item)" link>
  21. <text class="bianji" v-if="item.is_done==0">上传</text>
  22. </view>
  23. <text @click="isRead(item)" class="detail isread " v-if="item.is_read==0&&item.is_done==0">已阅</text>
  24. <text @click.native="onNoticeClick(item)" class="detail">查看详情</text>
  25. </view>
  26. </uni-card>
  27. </view>
  28. <view v-else-if="tableData.length==0 && isLoaded" style="text-align: center;">
  29. <view class="text-gray" style="padding-top: 20px;">
  30. <img :src="tan90" alt="暂无数据" />
  31. </view>
  32. </view>
  33. <view>
  34. <!-- <image :src="Group" @click="addClick" class="tiantupian"></image> -->
  35. </view>
  36. <!--
  37. <u-list @scrolltolower="scrolltolower" class="card">
  38. <u-list-item v-for="(item, index) in tableData" :key="index" @click.native="onNoticeClick(item)" link>
  39. <uni-row class="demo-uni-row padding-top text-sm" :gutter="20" width="100%">
  40. <uni-col :span="24" class="text-1cut">
  41. <rich-text :nodes="item.title" class="font-12"></rich-text>
  42. <text class="uni-body font-14 text-bold ">{{item.title}}</text>
  43. </uni-col>
  44. </uni-row>
  45. <uni-row class="demo-uni-row padding-top text-sm" :gutter="20" width="100%">
  46. <uni-col :span="24" class="text-2cut">
  47. <rich-text :nodes="item.content" class="font-12"></rich-text>
  48. <text class="uni-body">{{item.comContent}}</text>
  49. </uni-col>
  50. </uni-row>
  51. <uni-row class="demo-uni-row padding-tb-sm text-sm" :gutter="20" width="100%">
  52. <uni-col :span="24" class=" text-grey1 ">
  53. <text class="uni-body flex justify-end ">{{item.createTime}}</text>
  54. <text class="uni-body flex justify-end ">09-26</text>
  55. </uni-col>
  56. </uni-row>
  57. <u-button type="primary" text="详情" plain size="small" style="width: 20%;float: right;"></u-button>
  58. </u-list-item>
  59. </u-list> -->
  60. <tarBar :totarBer='tar'></tarBar>
  61. <u-popup :show="showComplete" title="完成提醒" mode="center">
  62. <view style="width:550rpx;height: 900rpx;margin: 20rpx 20rpx;position: relative;overflow-y: auto;">
  63. <view class="titles-popup">完成描述:</view>
  64. <u--textarea v-model="formData.donetext" placeholder="请输入内容" :maxlength="500" count
  65. height="150">
  66. </u--textarea>
  67. <view class="titles-popup">
  68. 附件上传:
  69. </view>
  70. <uni-file-picker v-model="formData.fileUrls" del-icon limit="5" file-mediatype="all"
  71. @select="selectFile" @delete="deleteFile">
  72. <button type="primary" class="selectBtn">选择文件</button>
  73. <!-- 加载中 -->
  74. <isLodingModel v-if="loading"></isLodingModel>
  75. </uni-file-picker>
  76. <view style="position:absolute;bottom:20px;width: 100%;">
  77. <view style="display: flex;justify-content: space-around;align-items: center;width: 100%;">
  78. <button class="antherBtn" @click="makeSure" style="background-color: #4cb2b6;color: #fff;">确认</button>
  79. <button class="antherBtn" @click="showComplete = false">取消</button>
  80. </view>
  81. </view>
  82. </view>
  83. </u-popup>
  84. <!-- 加载中 -->
  85. <isLodingModel></isLodingModel>
  86. </view>
  87. </template>
  88. <script>
  89. import tarBar from '@/components/tabBar/index' //先把tabBar.vue组件导入
  90. import {
  91. getRemindBroadPage,// 重要通知列表
  92. setisread,//是否已阅
  93. remindBroadFinish,
  94. getRemindOlnyRead
  95. } from "@/api/remind";
  96. import {
  97. uploadFileComp
  98. } from '@/utils/common.js';
  99. import {
  100. parseTime // 时间戳转换
  101. } from '@/utils/ruoyi';
  102. import config from '@/config'
  103. let that = null;
  104. const baseUrlImg = config.baseUrlImg
  105. export default {
  106. components: {
  107. tarBar
  108. },
  109. data() {
  110. return {
  111. isLoaded: false,
  112. tar: {
  113. color: '#07A7E3',
  114. id: 1
  115. }, //向子组件发送的值
  116. // 数据
  117. tableData: [],
  118. // 每页数据量
  119. pageSize: 10,
  120. // 当前页
  121. pageNo: 1,
  122. // 数据总量
  123. total: 0,
  124. // tableData数据加载中
  125. loading: false,
  126. // 初始化时搜索框的值
  127. keyword: '',
  128. ids: '0',
  129. title: '1',
  130. tan90: `${baseUrlImg}/tan90.png`,
  131. formData: {
  132. fileUrls: [],
  133. donetext: '', //上传描述内容
  134. doneDate:'',//完成时间
  135. attId:[],
  136. broadId:null,
  137. broadType:null
  138. },
  139. showComplete:false
  140. }
  141. },
  142. // 在 vue页面,向起始页通过事件传递数据
  143. onLoad: function(option) {
  144. this.ids = option.id
  145. },
  146. onShow() {
  147. this.tableData = []
  148. // this.tableD
  149. this.getData(1)
  150. },
  151. watch: {
  152. loading: {
  153. handler(newLength, oldLength) {
  154. this.$modal.isLoadingModel(this.loading)
  155. },
  156. immediate: true
  157. }
  158. },
  159. methods: {
  160. handleQuery() { //搜索
  161. this.isLoaded = false
  162. this.loading = true
  163. this.tableData = []
  164. this.getData(1)
  165. },
  166. // 获取数据
  167. getData(pageNo, value = '') {
  168. this.loading = true
  169. this.pageNo = pageNo
  170. const deptId = uni.getStorageSync('getUserInfo_key')?.streetInfo?uni.getStorageSync('getUserInfo_key').streetInfo.id:uni.getStorageSync('getUserInfo_key').userInfo.deptId;
  171. const userId = uni.getStorageSync('getUserInfo_key')?.userInfo?.id;
  172. console.log(pageNo,'00000000');
  173. getRemindBroadPage({
  174. pageNo: this.pageNo,
  175. pageSize: this.pageSize,
  176. reciver: deptId,
  177. userId: userId,
  178. remindTitle:this.keyword
  179. }).then(response => {
  180. this.isLoaded = true
  181. response.data.records.forEach(item=>{
  182. item.pubDate = parseTime(item.pub_date,"{y}-{m}-{d}")
  183. })
  184. // 为数据赋值:通过展开运算符的形式,进行新旧数据的拼接
  185. this.tableData = [...this.tableData, ...response.data.records]
  186. // this.tableData = response.data.list;
  187. this.total = response.data.total;
  188. this.loading = false;
  189. });
  190. },
  191. isRead(item){
  192. const arr = [];
  193. arr[0]=item.broad_id
  194. setisread({broadIds:arr}).then(res=>{
  195. this.tableData = [];
  196. this.getData(1);
  197. this.$forceUpdate()
  198. })
  199. },
  200. uploadButton(item){
  201. this.showComplete=true;
  202. this.formData.attId = [];
  203. this.formData.broadId = item.broad_id;
  204. this.formData.broadType = item.broad_type
  205. this.formData.fileUrls=[];
  206. this.formData.donetext = ''
  207. },
  208. // 移出图片函数
  209. async deleteFile(e) {
  210. this.formData.attId.forEach((item,index)=>{
  211. console.log(e.tempFilePath,'-------------');
  212. if(item.id==e.tempFilePath){
  213. this.formData.attId.splice(index, 1);
  214. }
  215. })
  216. // this.formData.fileUrls = [];
  217. },
  218. selectFile(e) {
  219. console.log(e.tempFilePaths,'e.tempFilePaths');
  220. let promises = [];
  221. for (let i = 0; i < e.tempFilePaths.length; i++) {
  222. const promise2 = uploadFileComp(e.tempFilePaths, i, this,this.formData.attId.length);
  223. this.$forceUpdate()
  224. promises.push(promise2);
  225. }
  226. Promise.all(promises).then(result => {
  227. console.log(result,'result====');
  228. // 处理上传文件成功的结果
  229. }).catch(error => {
  230. // 处理上传文件失败的错误
  231. });
  232. },
  233. //上传文件点击确认
  234. makeSure(){
  235. this.formData.doneDate = parseTime(new Date(),"{y}-{m}-{d}");
  236. this.formData.attId.forEach(item=>{
  237. this.formData.fileUrls.push(item.path)
  238. })
  239. console.log('sdfsf',this.formData);
  240. remindBroadFinish(this.formData).then(res=>{
  241. this.$modal.msgSuccess('上传成功');
  242. this.showComplete=false;
  243. this.tableData = [];
  244. this.getData(1);
  245. this.$forceUpdate()
  246. }).catch(err=>{
  247. this.$modal.msgSuccess('上传失败');
  248. this.showComplete=false;
  249. })
  250. },
  251. // 单个公告详情点击事件
  252. onNoticeClick(val) {
  253. this.isLoaded = false
  254. uni.navigateTo({
  255. url: `/pagesA/fire/remind/details/details?id=${val.broad_id}`,
  256. success: function(res) {
  257. // 通过eventChannel向被打开页面传送数据
  258. res.eventChannel.emit('acceptDataFromOpenerPage', val)
  259. }
  260. })
  261. },
  262. // scrolltolower() {
  263. // // 判断是否还有下一页数据
  264. // if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  265. // title: `数据加载完毕`
  266. // })
  267. // // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  268. // if (this.loading) return
  269. // this.pageNo += 1
  270. // this.getData(this.pageNo)
  271. // },
  272. },
  273. // 触底的事件
  274. onReachBottom() {
  275. console.log(this.pageSize,this.pageNo,this.total);
  276. // 判断是否还有下一页数据
  277. if (this.pageNo * this.pageSize >= this.total) return uni.showToast({
  278. title: `数据加载完毕`
  279. })
  280. // 判断是否正在请求其它数据,如果是,则不发起额外的请求
  281. if (this.loading) return
  282. this.pageNo += 1
  283. this.getData(this.pageNo)
  284. },
  285. }
  286. </script>
  287. <style lang="scss" scoped>
  288. body {
  289. background-color: #F5F7F9;
  290. }
  291. page {
  292. background-color: #F5F7F9;
  293. }
  294. .an-niu {
  295. float: right;
  296. font-size: 10px;
  297. text-align: center;
  298. display: flex;
  299. padding-bottom: 30rpx;
  300. margin-top: 50rpx;
  301. color: #fff;
  302. cursor: pointer;
  303. .detail {
  304. width: 72px;
  305. height: 60rpx;
  306. border-radius: 30px;
  307. background-color: #F7C41E;
  308. margin-right: 20rpx;
  309. text-align: center;
  310. line-height: 60rpx;
  311. }
  312. .isread {
  313. background-color: #18a2f7;
  314. }
  315. }
  316. //列表样式
  317. .titles {
  318. font-weight: 600;
  319. margin-bottom: 10rpx;
  320. font-size: 14px;
  321. }
  322. /deep/.uni-card {
  323. box-shadow: 0px 0px 3px 0px rgba(86, 165, 168, 0.63) !important;
  324. border-radius: 30rpx;
  325. }
  326. rich-text {
  327. display: -webkit-box;
  328. -webkit-box-orient: vertical;
  329. -webkit-line-clamp: 1;
  330. overflow: hidden;
  331. }
  332. .selectBtn {
  333. width: 200rpx;
  334. margin-left: 0;
  335. font-size: 30rpx;
  336. background-color: #4cb2b6;
  337. }
  338. .titles-popup{
  339. margin: 10px 10px;
  340. font-weight: 600;
  341. font-size: 14px;
  342. }
  343. ::v-deep .uni-file-picker__lists{
  344. height: 200rpx;
  345. overflow-y: auto;
  346. }
  347. </style>