template1.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. <template>
  2. <view class="content-area">
  3. <view class="content-area-title font12 mtb5 plr10">实时保存,保存时间 {{ saveTime }}</view>
  4. <view class="content-area-item p10 bg-white">
  5. <view class="font14 weight mb10">工作内容</view>
  6. <u-collapse v-if="form.workContents.length > 0" :accordion="true">
  7. <u-collapse-item :title="item.projectName + ' ' + (item.workTime ? item.workTime + 'h' : '0h')" :name="item.projectId" v-for="(item, index) in form.workContents" :key="index">
  8. <u-input
  9. v-model="item.workTime"
  10. placeholder="请输入工作耗时"
  11. placeholderStyle="color:#909399;font-size:12px"
  12. suffixIcon="h"
  13. suffixIconStyle="color:#909399;font-size:12px;width:10px"
  14. border="none"
  15. type="digit"
  16. style="padding: 0px; margin: 10px 0"
  17. @change="realTimeSaving()"
  18. />
  19. <u-textarea
  20. v-model="item.workContent"
  21. placeholder="请输入工作内容"
  22. placeholderStyle="color:#909399;font-size:12px"
  23. confirmType="return"
  24. :autoHeight="true"
  25. :maxlength="-1"
  26. :height="'100%'"
  27. border="none"
  28. style="padding: 0px; margin: 10px 0"
  29. @change="realTimeSaving()"
  30. ></u-textarea>
  31. </u-collapse-item>
  32. </u-collapse>
  33. <u-button class="mt20" type="primary" style="width: 100px; height: 25px" @click="insertProjects()" shape="circle" icon="plus" size="mini"> 添加项目 </u-button>
  34. </view>
  35. <view class="content-area-item mt20 p10 bg-white">
  36. <view class="font14 weight mb10">明日计划</view>
  37. <u-textarea
  38. v-model="form.tomorrowPlan"
  39. placeholder="请输入"
  40. placeholderStyle="color:#909399;font-size:12px"
  41. confirmType="return"
  42. :autoHeight="true"
  43. :maxlength="-1"
  44. :height="'100%'"
  45. border="none"
  46. style="padding: 0px"
  47. @change="realTimeSaving()"
  48. ></u-textarea>
  49. </view>
  50. <view class="content-area-item mt20 p10 bg-white">
  51. <view class="font14 weight mb10">工作协调</view>
  52. <u-textarea
  53. v-model="form.coordinateWork"
  54. placeholder="请输入"
  55. placeholderStyle="color:#909399;font-size:12px"
  56. confirmType="return"
  57. :autoHeight="true"
  58. :maxlength="-1"
  59. :height="'100%'"
  60. border="none"
  61. style="padding: 0px"
  62. @change="realTimeSaving()"
  63. ></u-textarea>
  64. </view>
  65. <view class="content-area-item mt20 p10 bg-white">
  66. <view class="font14 weight mb10">抄送到人</view>
  67. <view class="flex flex-wrap">
  68. <view class="mr10 mb10" v-for="(user, index) in userList" :key="index" @click="deleteUsers(index)">
  69. <u-avatar
  70. class="content-area-item-avatar"
  71. :src="user.avatar ? user.avatar : '/static/images/404.png'"
  72. shape="square"
  73. size="40"
  74. fontSize="12"
  75. color="#ffffff"
  76. :bgColor="$settingStore.themeColor.color"
  77. v-if="user.avatar"
  78. ></u-avatar>
  79. <u-avatar
  80. class="content-area-item-avatar"
  81. :text="user.label.length > 2 ? user.label.slice(1, 3) : user.label"
  82. shape="square"
  83. size="40"
  84. fontSize="12"
  85. color="#ffffff"
  86. :bgColor="$settingStore.themeColor.color"
  87. v-else
  88. ></u-avatar>
  89. <view class="font12 text-center mt5">{{ user.label }}</view>
  90. </view>
  91. </view>
  92. <u-button class="mt20" type="primary" style="width: 100px; height: 25px" @click="insertUsers()" shape="circle" icon="plus" size="mini"> 选择人员 </u-button>
  93. </view>
  94. </view>
  95. <view class="content-area-item mt20 p10 bg-white">
  96. <view class="flex">
  97. <view class="font14 weight">同步钉钉</view>
  98. <u-switch
  99. style="margin-left: auto"
  100. :modelValue="form.sendDingTalk == 0 ? false : true"
  101. :ctiveColor="proxy.$settingStore.themeColor.color"
  102. size="20"
  103. @change="(event) => switchChage(event, 'sendDingTalk')"
  104. asyncChange
  105. ></u-switch>
  106. </view>
  107. <view class="flex"> </view>
  108. </view>
  109. <view class="content-area-item mt20 p10 bg-white">
  110. <view class="flex">
  111. <view class="font14 weight">定时发送</view>
  112. <u-switch
  113. style="margin-left: auto"
  114. :modelValue="form.isRegularlySend == 0 ? false : true"
  115. :ctiveColor="proxy.$settingStore.themeColor.color"
  116. size="20"
  117. @change="(event) => switchChage(event, 'isRegularlySend')"
  118. asyncChange
  119. ></u-switch>
  120. </view>
  121. <view class="flex" v-if="form.isRegularlySend == 0 ? false : true" @click="timeInputClick()">
  122. <u-input
  123. v-model="form.timingTime"
  124. placeholder="请选择时间"
  125. placeholderStyle="color:#909399;font-size:12px"
  126. suffixIcon="arrow-right"
  127. suffixIconStyle="color:#909399;font-size:12px;width:10px"
  128. border="none"
  129. style="padding: 0px; margin: 10px 0"
  130. @change="realTimeSaving()"
  131. disabledColor="transparent"
  132. disabled
  133. />
  134. </view>
  135. </view>
  136. <view class="app-button">
  137. <view class="app-button-padding"></view>
  138. <view class="app-button-fixed">
  139. <u-button class="app-buttom" type="primary" @click="handleSubmit('提交')" shape="circle"> 提交 </u-button>
  140. </view>
  141. </view>
  142. <u-datetime-picker :show="timeShow" v-model="timeValue" mode="datetime" :closeOnClickOverlay="true" @cancel="timeShow = false" @confirm="timeConfirm"></u-datetime-picker>
  143. <u-modal :show="modalShow" title="" :confirmText="'确定'" :cancelText="'取消'" :zoom="false" :showCancelButton="true" @confirm="modalConfirm" @cancel="modalShow = false">
  144. <view class="slot-content">
  145. <u-checkbox-group v-model="projectsCheck" placement="row" :size="14" v-if="projectsList.length > 0">
  146. <u-checkbox
  147. :customStyle="{ marginBottom: '8px', width: '50%' }"
  148. v-for="(item, index) in projectsList"
  149. :key="index"
  150. :label="item.projectName"
  151. :name="item.id"
  152. :activeColor="proxy.$settingStore.themeColor.color"
  153. >
  154. </u-checkbox>
  155. </u-checkbox-group>
  156. <view v-else>请联系项目管理人员给您分配项目后重试!</view>
  157. </view>
  158. </u-modal>
  159. </template>
  160. <script setup>
  161. /*----------------------------------依赖引入-----------------------------------*/
  162. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  163. import { ref, reactive, computed, getCurrentInstance, toRefs, inject } from "vue";
  164. /*----------------------------------接口引入-----------------------------------*/
  165. import { projectApi } from "@/api/business/project.js";
  166. /*----------------------------------组件引入-----------------------------------*/
  167. /*----------------------------------store引入-----------------------------------*/
  168. /*----------------------------------公共方法引入-----------------------------------*/
  169. import { storageSystem } from "@/utils/storage"; // 公共方法引用
  170. /*----------------------------------公共变量-----------------------------------*/
  171. const { proxy } = getCurrentInstance();
  172. /*----------------------------------变量声明-----------------------------------*/
  173. const state = reactive({
  174. timeShow: false,
  175. timeValue: Number(new Date()),
  176. modalShow: false,
  177. form: {
  178. reportDate: null,
  179. tomorrowPlan: "",
  180. ccTo: "",
  181. coordinateWork: null,
  182. workContents: [],
  183. sendDingTalk: 1,
  184. isRegularlySend: 0,
  185. timingTime: null,
  186. reportStatus: null,
  187. },
  188. projectsCheck: [],
  189. projectsList: [],
  190. userList: [],
  191. saveTime: "",
  192. });
  193. const { timeShow, timeValue, modalShow, form, projectsCheck, projectsList, userList, saveTime } = toRefs(state);
  194. /**
  195. * @初始化
  196. */
  197. function init() {
  198. projectApi()
  199. .ProjectsList()
  200. .then((requset) => {
  201. state.projectsList = requset.data;
  202. });
  203. }
  204. /** 定时发送输入框点击事件 */
  205. function timeInputClick() {
  206. state.timeShow = true;
  207. }
  208. /** 时间选择器确定按钮点击事件 */
  209. function timeConfirm() {
  210. state.form.timingTime = proxy.$common.formatterDateTime(state.timeValue);
  211. state.timeShow = false;
  212. }
  213. /** 开关按钮change事件 */
  214. function switchChage(e, key) {
  215. state.form[key] = e == true ? 1 : 0;
  216. if (key === "isRegularlySend") {
  217. state.form.timingTime = null;
  218. }
  219. realTimeSaving();
  220. }
  221. /** 添加人员按钮事件 */
  222. function insertUsers() {
  223. proxy.$tab.navigateTo(`/pages/business/common/projectMange/mall/index`);
  224. }
  225. /** 删除人员按钮事件 */
  226. function deleteUsers(index) {
  227. state.userList.splice(index, 1);
  228. realTimeSaving();
  229. }
  230. /** 添加项目按钮事件 */
  231. function insertProjects() {
  232. state.modalShow = true;
  233. }
  234. /** 实时保存填写数据 */
  235. function realTimeSaving() {
  236. state.saveTime = proxy.$common.formatterDate(new Date(), "hh:mm");
  237. storageSystem.set("project", state);
  238. }
  239. /** 弹窗确定 */
  240. function modalConfirm() {
  241. var newWorkContents = JSON.parse(JSON.stringify(state.form.workContents));
  242. state.form.workContents = [];
  243. state.projectsCheck.forEach((e) => {
  244. state.form.workContents.push({
  245. projectId: e,
  246. projectName: proxy.$common.mapping("projectName", "id", e, state.projectsList),
  247. workTime: "",
  248. workContent: "",
  249. });
  250. });
  251. newWorkContents.forEach((e) => {
  252. state.form.workContents.forEach((f) => {
  253. if (e.projectId == f.projectId) {
  254. f.workTime = e.workTime;
  255. f.workContent = e.workContent;
  256. }
  257. });
  258. });
  259. state.modalShow = false;
  260. realTimeSaving();
  261. }
  262. /** 提交 */
  263. function handleSubmit() {
  264. if (!state.form.tomorrowPlan) {
  265. proxy.$modal.showToast("请输入明日计划");
  266. }
  267. state.form.ccTo = state.userList.map((obj) => `${obj.id}`).join(",");
  268. state.form.reportDate = proxy.$common.formatterDate(new Date(), "yyyy-MM-dd");
  269. state.form.workContents.forEach((e) => {
  270. e.workTime = parseInt(e.workTime);
  271. });
  272. projectApi()
  273. .Insert(state.form)
  274. .then((requset) => {
  275. proxy.$tab.redirectTo("/pages/business/common/projectMange/record/index"); //返回到需要执行方法的页面
  276. state.form = {
  277. workContents: [],
  278. tomorrowPlan: "",
  279. coordinateWork: null,
  280. };
  281. storageSystem.set("project", state);
  282. });
  283. }
  284. onReady(() => {});
  285. onShow(() => {
  286. //循环将缓存数据遍历
  287. var storages = storageSystem.get("project");
  288. Object.keys(storages).forEach((key) => {
  289. state[key] = storages[key];
  290. });
  291. //监听组件返回数据
  292. uni.$on("UserMall", function (value) {
  293. state.userList = value;
  294. realTimeSaving();
  295. });
  296. });
  297. onLoad((options) => {
  298. init();
  299. });
  300. onUnload(() => {
  301. uni.$off("UserMall"); //将值删除监听器
  302. });
  303. </script>
  304. <style lang="scss" scoped>
  305. :deep(.u-cell__body) {
  306. color: #000000;
  307. font-size: 12px;
  308. padding: 10px 0px !important;
  309. }
  310. :deep(.u-collapse-item__content) {
  311. overflow: auto;
  312. height: auto !important;
  313. }
  314. :deep(.u-collapse-item__content__text) {
  315. padding: 0;
  316. }
  317. :deep(.u-cell__left-icon-wrap) {
  318. margin: 0;
  319. }
  320. .content-area {
  321. &-title {
  322. text-align: right;
  323. color: #909399;
  324. }
  325. &-item {
  326. &-avatar {
  327. position: relative;
  328. &::after {
  329. position: absolute;
  330. content: "✖";
  331. display: inline-block;
  332. padding: 2px 4px;
  333. border-radius: 100%;
  334. cursor: pointer;
  335. font-size: 8px;
  336. text-align: center;
  337. background-color: #ccc;
  338. color: #fff;
  339. top: -5px;
  340. right: -5px;
  341. }
  342. &::after:hover {
  343. background-color: #ccc;
  344. }
  345. }
  346. }
  347. }
  348. </style>