timingLog.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <u-sticky class="shadow-default" bgColor="#fff" style="top: 0">
  3. <u-navbar :titleStyle="{ color: '#000' }" :autoBack="true" title="定时日志" :placeholder="true" :safeAreaInsetTop="true" bgColor="#fff">
  4. </u-navbar>
  5. </u-sticky>
  6. <oa-scroll
  7. customClass="record-container scroll-height"
  8. :pageSize="pageSize"
  9. :total="total"
  10. :isSticky="true"
  11. :customStyle="{
  12. //#ifdef APP-PLUS || MP-WEIXIN
  13. height: 'calc(100vh - 40px)',
  14. //#endif
  15. //#ifdef H5
  16. height: 'calc(100vh - 40px)',
  17. //#endif
  18. }"
  19. :refresherLoad="true"
  20. :refresherEnabled="true"
  21. :refresherDefaultStyle="'none'"
  22. :refresherThreshold="44"
  23. :lowerThreshold="44"
  24. :refresherBackground="'#f5f6f7'"
  25. @load="load"
  26. @refresh="refresh"
  27. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  28. >
  29. <template #default>
  30. <u-loading-page :loading="state.loading" fontSize="16" style="z-index: 99"></u-loading-page>
  31. <view class="content-area" v-for="(group, date) in proxy.$common.groupedItems(state.timedList, 'submitDate')" :key="date">
  32. <view class="content-area-time font14">{{ proxy.$time.jktTimes(date, "否") }}</view>
  33. <view class="content-area-center bg-white" v-for="(el, ind) in group" :key="ind">
  34. <view class="content-area-top menu-item" style="float:right;padding:10px 0px">
  35. <view class="content-area-top-time"> </view>
  36. <u-icon class="content-area-top-icon" name="more-dot-fill" size="20" color="#000" @click="moreClick(el)"></u-icon>
  37. </view>
  38. <view class="flex mb10" @click="goContentDetails(el)">
  39. <u-avatar
  40. class="content-area-center-avatar mr10"
  41. :text="el.createBy.length > 2 ? el.createBy.slice(1, 3) : el.createBy"
  42. shape="square"
  43. size="35"
  44. fontSize="10"
  45. color="#ffffff"
  46. :bgColor="proxy.$settingStore.themeColor.color"
  47. ></u-avatar>
  48. <view>
  49. <view class="content-area-center-title font14 mb5">{{ el.createBy }}的日报</view>
  50. <!-- <view class="content-area-center-time font12">{{ proxy.$time.jktTimes(el.submitDate.replace("T", " ")) }}</view> -->
  51. </view>
  52. </view>
  53. <view class="mb5" @click="goContentDetails(el)">
  54. <u-text :text="el.contentText.length >= 100 ? el.contentText.slice(0, 100) + '···' : el.contentText" color="#666666" size="14"></u-text>
  55. </view>
  56. <view style="font-size:12px;color:#a7a4a4">
  57. <u-button size="mini" style="width:50px;float:left;margin-right:5px;line-height:18px;height:18px">定时日志</u-button>
  58. 将于 {{ el.timingTime.replace("T", " ").slice(0, 16) }} 发布
  59. </view>
  60. </view>
  61. </view>
  62. </template>
  63. </oa-scroll>
  64. <u-popup :show="popup.show" mode="bottom" bgColor="#fff" :round="10" @close="popup.show = false">
  65. <view
  66. :style="{
  67. borderTopLeftRadius: '10px',
  68. borderTopRightRadius: '10px',
  69. overflow: 'hidden',
  70. }"
  71. >
  72. <u-button
  73. class="custom-style"
  74. type="info"
  75. size="normal"
  76. text="编辑"
  77. :customStyle="{
  78. height: '50px',
  79. color: '#3c9cff',
  80. borderWidth: 0,
  81. borderRadius: 0,
  82. borderBottomWidth: '1px',
  83. }"
  84. @click="handleSubmit('update', eventList)"
  85. ></u-button>
  86. <u-button
  87. class="custom-style"
  88. type="info"
  89. size="normal"
  90. text="删除"
  91. :customStyle="{
  92. height: '50px',
  93. color: '#f56c6c',
  94. borderWidth: 0,
  95. borderRadius: 0,
  96. borderBottomWidth: '3px',
  97. }"
  98. @click="handleModal('delete', `确认删除“ ${eventList.createBy} ” 的“ ${eventList.reportDate} ” 的日报?`)"
  99. ></u-button>
  100. <u-button
  101. class="custom-style"
  102. type="info"
  103. size="normal"
  104. text="取消"
  105. :customStyle="{
  106. height: '50px',
  107. color: '#3c9cff',
  108. border: 'none',
  109. borderRadius: 0,
  110. }"
  111. @click="popup.show = false"
  112. ></u-button>
  113. </view>
  114. </u-popup>
  115. <uni-popup ref="alertDialog" type="dialog">
  116. <uni-popup-dialog :type="state.tip.type" cancelText="取消" confirmText="确定" title="操作提醒" :content="state.tip.content" @confirm="dialogConfirm"
  117. @close="dialogClose"></uni-popup-dialog>
  118. </uni-popup>
  119. <u-modal
  120. :show="modal.show"
  121. title="操作提醒"
  122. :content="modal.content"
  123. :showCancelButton="true"
  124. :closeOnClickOverlay="true"
  125. @confirm="handleSubmit(state.modal.type, eventList)"
  126. @cancel="modal.show = false"
  127. @close="modal.show = false"
  128. ></u-modal>
  129. </template>
  130. <script setup>
  131. /*----------------------------------依赖引入-----------------------------------*/
  132. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  133. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  134. /*----------------------------------接口引入-----------------------------------*/
  135. import { projectApi } from "@/api/business/project.js";
  136. /*----------------------------------组件引入-----------------------------------*/
  137. /*----------------------------------store引入-----------------------------------*/
  138. import { useStores, commonStores } from "@/store/modules/index";
  139. /*----------------------------------公共方法引入-----------------------------------*/
  140. /*----------------------------------公共变量-----------------------------------*/
  141. const { proxy } = getCurrentInstance();
  142. const useStore = useStores();
  143. /*----------------------------------变量声明-----------------------------------*/
  144. const state = reactive({
  145. loading: false,
  146. pageSize: 20,
  147. current: 1,
  148. total: 0,
  149. popup: {
  150. show: false, //弹窗显示
  151. content: "", //提示信息
  152. },
  153. modal: {
  154. type: "", //操作类型
  155. show: false, //弹窗显示
  156. content: "", //提示信息
  157. },
  158. eventList: {}, //数据存储
  159. tip:{
  160. type:undefined,//弹框类型
  161. content:"",//提示信息
  162. data:{},//带入数据
  163. operation:undefined,//操作类型
  164. },
  165. timedList:[]
  166. });
  167. const {pageSize, current, total,popup,eventList,modal,timedList} = toRefs(state);
  168. /**
  169. * 操作弹框提醒
  170. * @param type 弹框类型
  171. * @param content 提示内容
  172. * @param item 带入数据
  173. * @param operation 操作类型
  174. */
  175. function tips(type,content,item,operation){
  176. state.tip.type=type
  177. state.tip.content=content
  178. state.tip.data=item
  179. state.tip.operation=operation
  180. proxy.$refs.alertDialog.open()
  181. }
  182. /**弹框确定操作 */
  183. function dialogConfirm(){
  184. if(state.tip.operation =='delete'){
  185. handleSubmit('delete',state.tip.data)
  186. }
  187. if(state.tip.operation=='exit'){
  188. handleSubmit('exit',state.tip.data)
  189. }
  190. }
  191. /**
  192. * @初始化
  193. */
  194. function init() {
  195. projectApi()
  196. .TimedReports({
  197. }).then((requset) => {
  198. state.timedList = requset.data;
  199. requset.data.forEach((el) => {
  200. el.contentText = "";
  201. el.workContents.forEach((cl) => {
  202. el.contentText += `${cl.projectName} ${cl.workTime}h \n ${cl.workContent}`;
  203. });
  204. });
  205. state.total = requset.data.length;
  206. state.loading = false;
  207. })
  208. .catch((err) => {
  209. state.loading = false;
  210. })
  211. }
  212. /**
  213. * @跳转详情
  214. */
  215. function goContentDetails(e) {
  216. // proxy.$tab.navigateTo(`/pages/business/common/projectMange/record/details?reportId=${e.id}`);
  217. }
  218. /**
  219. * @scrollView加载数据
  220. */
  221. function load() {
  222. init();
  223. }
  224. /**
  225. * @scrollView刷新数据
  226. */
  227. function refresh() {
  228. init();
  229. }
  230. /** 更多按钮点击事件 */
  231. function moreClick(event) {
  232. state.popup.show = true;
  233. state.eventList = event;
  234. }
  235. /** 确认按钮点击事件 */
  236. function handleModal(type, content) {
  237. state.modal.show = true;
  238. state.modal.type = type;
  239. state.modal.content = content;
  240. }
  241. /** 编辑、删除日报*/
  242. function handleSubmit(type,item) {
  243. if (type === "update") {
  244. proxy.$tab.navigateTo(`/pages/business/common/projectMange/write/insert?templateId=1&id=${item.id}`);
  245. state.modal.show = false;
  246. } else if (type === "delete") {
  247. projectApi()
  248. .ReportDelete(item.id)
  249. .then(() => {
  250. proxy.$modal.msg("日报删除成功!");
  251. state.modal.show = false;
  252. state.popup.show = false;
  253. init();
  254. })
  255. .catch((errors) => {
  256. proxy.$modal.msg(errors);
  257. });
  258. }
  259. }
  260. onReady(() => {});
  261. onShow(() => {
  262. state.popup.show = false;
  263. //调用系统主题颜色
  264. proxy.$settingStore.systemThemeColor([1]);
  265. });
  266. onLoad((options) => {
  267. init();
  268. uni.$on("projectMange_record", function (value) {
  269. init();
  270. });
  271. });
  272. onUnload(() => {
  273. uni.$off("projectMange_record"); //将值删除监听器
  274. });
  275. </script>
  276. <style lang="scss" scoped>
  277. .content-area {
  278. &-time {
  279. padding: 10px;
  280. text-align: left;
  281. color: #000000;
  282. font-weight: 600;
  283. }
  284. &-center {
  285. margin: 0;
  286. padding: 15px;
  287. overflow: hidden;
  288. border-bottom: 1px solid #eaeef1;
  289. &:last-child {
  290. border-bottom: 0px solid #eaeef1;
  291. }
  292. &-avatar {
  293. margin: auto 0;
  294. }
  295. &-title {
  296. margin: 0 0 15px 0;
  297. font-weight: 600;
  298. color: #000000;
  299. }
  300. }
  301. }
  302. .pp{
  303. text-align: left;
  304. }
  305. </style>
  306. <style>
  307. .pp .u-modal__content{
  308. justify-content: left !important
  309. }
  310. </style>