weekly.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. <template>
  2. <view>
  3. <view style="display: flex;justify-content: center;margin: 30rpx;font-size:30rpx ;align-items: center;">
  4. <u-icon name="arrow-left-double" style="font-size: 40rpx;margin-right: 30rpx;" @click="previous"></u-icon>
  5. <div @click="show = true">
  6. {{"第"+weekNum+'周('+weeList[0]+"至"+weeList[weeList.length-1]+')' }}
  7. </div>
  8. <u-icon name="arrow-right-double" style="font-size: 40rpx;margin-left: 30rpx;" @click="next"></u-icon>
  9. </view>
  10. <u-divider></u-divider>
  11. <view class="">
  12. <uni-section v-for="(item, index) in list" :key="index" :title="item.deptName" type="line">
  13. <uni-card style="height: 210rpx;">
  14. <text class="uni-body">提交人:{{item.createBy}}</text>
  15. <br>
  16. <text class="uni-body">提交时间:{{item.createTime}}</text>
  17. <view style="display: flex;margin-top: 20rpx; position: absolute;
  18. left:50%;
  19. transform: translateX(-50%);
  20. " class="uni-group">
  21. <!-- v-if="nowLogin==item.createBy||viewRow" -->
  22. <u-button style="width:20rpx;" @click="handleView(item)" class="uni-button" size="small"
  23. type="warning">查看</u-button>
  24. <u-button style="width: 20rpx;margin-left: 20rpx;width:20rpx;" size="small"
  25. @click="handleUpdate(item)" class="uni-button" type="primary">修改</u-button>
  26. <u-button style="width: 20rpx;margin-left: 20rpx;" @click="handleDelete(item)"
  27. class="uni-button" size="small" type="error">删除</u-button>
  28. </view>
  29. </uni-card>
  30. <u-divider></u-divider>
  31. </uni-section>
  32. <!-- <uni-table ref="table" :loading="loading" border stripe emptyText="暂无更多数据">
  33. <uni-tr>
  34. <uni-th width="170rpx" align="center">提交人</uni-th>
  35. <uni-th width="240rpx" align="center">部门名称</uni-th>
  36. <uni-th width="270rpx" align="center">提交时间</uni-th>
  37. <uni-th align="center">设置</uni-th>
  38. </uni-tr>
  39. <uni-tr v-for="(item, index) in list" :key="index">
  40. <uni-td align="center">{{ item.createBy }}</uni-td>
  41. <uni-td align="center">
  42. <view class="name">{{ item.deptName }}</view>
  43. </uni-td>
  44. <uni-td align="center">{{ item.createTime }}</uni-td>
  45. <uni-td align="center">
  46. <view style="display: flex;" class="uni-group">
  47. <u-button v-if="nowLogin==item.createBy" size="small" @click="handleUpdate(item)"
  48. class="uni-button" type="primary">修改</u-button>
  49. <u-button v-if="nowLogin==item.createBy" style="margin-left: 10rpx;"
  50. @click="handleDelete(item)" class="uni-button" size="small" type="error">删除</u-button>
  51. <u-button v-if="viewRow" style="margin-left: 10rpx;width:20rpx;" @click="handleView(item)"
  52. class="uni-button" size="small" type="warning">查看</u-button>
  53. </view>
  54. </uni-td>
  55. </uni-tr>
  56. </uni-table> -->
  57. <!-- <view class="uni-pagination-box"><uni-pagination show-icon :page-size="pageSize" :current="pageCurrent"
  58. :total="total" @change="change" /></view> -->
  59. <u-modal :show="showModal" title="确认操作" content="您确定要删除该周报吗?" show-cancel-button cancel-text="取消"
  60. confirm-text="确定" @cancel="handleCancel" @confirm="handleConfirm"></u-modal>
  61. </view>
  62. <u-datetime-picker :show="show" v-model="today" mode="date" @confirm="confirm"
  63. @cancel="show=false"></u-datetime-picker>
  64. </view>
  65. </template>
  66. <script>
  67. import {
  68. getWeekInYear,
  69. getNowWeekList
  70. } from "@/utils/wjw.js"
  71. export default {
  72. data() {
  73. return {
  74. model: {
  75. pageNum: 1,
  76. pageSize: 5,
  77. periods: null
  78. },
  79. //加载状态
  80. status: 'loadmore',
  81. viewRow: false,
  82. hasMore: true, // 是否有更多数据
  83. showModal: false,
  84. nowLogin: '',
  85. searchVal: '',
  86. tableData: [],
  87. // 每页数据量
  88. pageSize: 10,
  89. // 当前页
  90. pageCurrent: 1,
  91. // 数据总量
  92. total: 0,
  93. loading: false,
  94. list: [], //人员列表
  95. nowWeekNum: null, //当前周数
  96. //当前周数
  97. weekNum: null,
  98. weeList: [], //周日期列表
  99. nowWeeList: [], //当前周日期列表
  100. xiugaiDay: null, //可修改日期
  101. today: null, //当前日期
  102. show: false, //日历展示
  103. xgType: true, //是否能修改
  104. day: null, //当前日期
  105. mounth: null, //当前月
  106. year: null, //当前年
  107. rowNow: null
  108. }
  109. },
  110. onLoad() {
  111. this.selectedIndexs = []
  112. this.list = []
  113. this.today = new Date().getTime()
  114. this.nowWeekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  115. this.weekNum = getWeekInYear(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  116. this.weeList = getNowWeekList(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  117. this.nowWeeList = getNowWeekList(uni.$u.timeFormat(new Date().toLocaleDateString(), 'yyyy-mm-dd'))
  118. this.model.periods = this.weekNum
  119. this.getPeople()
  120. let roles = uni.getStorageSync('userInfo').roles
  121. this.nowLogin = uni.getStorageSync('userInfo').nickName
  122. console.log('roles', roles)
  123. for (let i in roles) {
  124. // this.nowLogin.push(roles[i].roleName)
  125. if (roles[i].roleKey == 'admin' || roles[i].roleKey == 'zhoubaoGly') {
  126. this.viewRow = true
  127. }
  128. }
  129. // this.getModifyDay()
  130. },
  131. onNavigationBarButtonTap() {
  132. uni.navigateTo({
  133. url: `/pages/weeklySubmit/weeklySubmit?title=周报新增`
  134. })
  135. },
  136. onShow() {
  137. uni.$once('query', (query) => {
  138. if (query.a === 1) {
  139. this.list = []
  140. this.model.pageNum = 1
  141. this.model.pageSize = 5
  142. this.getPeople()
  143. } else if (query.a == 2) {
  144. this.list = []
  145. this.model.pageNum = 1
  146. this.model.pageSize = 5
  147. this.getPeople()
  148. }
  149. });
  150. },
  151. onPullDownRefresh() {
  152. this.model.pageNum = 1
  153. this.list = []
  154. this.getPeople()
  155. },
  156. onReachBottom() {
  157. console.log('total', this.total)
  158. if (this.model.pageNum * this.model.pageSize >= this.total) {
  159. this.status = 'nomore'
  160. } else {
  161. this.model.pageNum++
  162. this.getPeople()
  163. }
  164. },
  165. methods: {
  166. handleUpdate(row) {
  167. uni.navigateTo({
  168. url: `/pages/weeklySubmit/weeklySubmit?title=周报修改&id=` + row.id
  169. })
  170. },
  171. handleView(row) {
  172. uni.navigateTo({
  173. url: `/pages/weeklySubmit/weeklySubmit?title=周报查看&showNo=no&id=` + row.id
  174. })
  175. },
  176. handleConfirm() {
  177. uni.$u.http.delete('/offcial/weekly/' + this.rowNow.id).then((res) => {
  178. uni.showToast({
  179. title: "删除成功",
  180. icon: "none"
  181. })
  182. this.showModal = false
  183. setTimeout(() => {
  184. this.list = []
  185. this.model.pageNum = 1
  186. this.model.pageSize = 5
  187. this.getPeople()
  188. }, 200)
  189. })
  190. },
  191. handleCancel() {
  192. this.showModal = false
  193. },
  194. handleDelete(row) {
  195. console.log('row', row);
  196. this.rowNow = row;
  197. this.showModal = true;
  198. // const _ids = row.id || ids.value;
  199. // proxy.$modal
  200. // .confirm("是否确认删除该周报?")
  201. // .then(function () {
  202. // return delWeekly(_ids);
  203. // })
  204. // .then(() => {
  205. // getList();
  206. // proxy.$modal.msgSuccess("删除成功");
  207. // })
  208. // .catch(() => {});
  209. },
  210. // 分页触发
  211. change(e) {
  212. this.$refs.table.clearSelection()
  213. this.selectedIndexs.length = 0
  214. this.getPeople(e.current)
  215. },
  216. //点击上一周
  217. previous() {
  218. uni.showLoading({
  219. title: "加载中...",
  220. mask: true
  221. })
  222. this.today = this.today - 7 * 86400000
  223. this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  224. this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  225. this.model.periods = this.weekNum
  226. this.getPeople()
  227. },
  228. //点击下一周
  229. next() {
  230. this.today = this.today + 7 * 86400000
  231. this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  232. this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  233. this.model.periods = this.weekNum
  234. this.getPeople()
  235. },
  236. //日历确认
  237. confirm(e) {
  238. this.today = e.value
  239. this.weekNum = getWeekInYear(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  240. this.weeList = getNowWeekList(uni.$u.timeFormat(this.today, 'yyyy-mm-dd'))
  241. this.show = false
  242. this.getPeople()
  243. },
  244. //获取列表人员
  245. getPeople() {
  246. let that = this
  247. uni.showLoading({
  248. title: "加载中...",
  249. mask: true
  250. })
  251. // {
  252. // periods: this.weekNum,
  253. // pageSize: this.pageSize,
  254. // pageNum: pageCurrent,
  255. // }
  256. uni.$u.http.get(`/offcial/weekly/list`, {
  257. params: that.model
  258. }).then(res => {
  259. uni.hideLoading()
  260. that.total = res.total
  261. that.list = [...that.list, ...res.rows]
  262. if (res.total < this.model.pageSize) {
  263. that.status = "nomore"
  264. } else {
  265. that.status = "loadmore"
  266. }
  267. if (that.model.pageNum == 1) {
  268. // that.total = Math.ceil(res.total / that.model.pageSize)
  269. that.total = res.total
  270. uni.stopPullDownRefresh()
  271. }
  272. }).catch((res) => {
  273. uni.hideLoading()
  274. uni.showToast({
  275. title: res.msg,
  276. icon: "none"
  277. })
  278. })
  279. },
  280. }
  281. }
  282. </script>
  283. <style>
  284. .uni-section .uni-section-header[data-v-f7ca1098] {
  285. position: relative;
  286. display: flex;
  287. flex-direction: row;
  288. align-items: center;
  289. padding: 2px 10px;
  290. font-weight: normal;
  291. }
  292. .uni-card {
  293. /* margin: 0px 15px !important */
  294. }
  295. .uni-section__content-title {
  296. font-size: 16px !important;
  297. }
  298. </style>