template1.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  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 required">工作内容</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 mt10 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 mt10 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 mt10 p10 bg-white">
  66. <view class="font14 weight mb10">抄送到人</view>
  67. <avatarList :userList="userList" @deleteUsers="deleteUsers" />
  68. <u-button class="mt20" type="primary" style="width: 100px; height: 25px" @click="insertUsers()" shape="circle" icon="plus" size="mini"> 选择人员 </u-button>
  69. </view>
  70. <view class="content-area-item mt10 p10 bg-white">
  71. <view class="flex">
  72. <view class="font14 weight">同步钉钉</view>
  73. <u-switch
  74. style="margin-left: auto"
  75. :modelValue="form.sendDingTalk == 0 ? false : true"
  76. :ctiveColor="proxy.$settingStore.themeColor.color"
  77. size="20"
  78. @change="(event) => switchChage(event, 'sendDingTalk')"
  79. asyncChange
  80. ></u-switch>
  81. </view>
  82. <view class="flex"> </view>
  83. </view>
  84. <view class="content-area-item mt10 p10 bg-white">
  85. <view class="flex">
  86. <view class="font14 weight">定时发送</view>
  87. <u-switch
  88. style="margin-left: auto"
  89. :modelValue="form.isRegularlySend == 0 ? false : true"
  90. :ctiveColor="proxy.$settingStore.themeColor.color"
  91. size="20"
  92. @change="(event) => switchChage(event, 'isRegularlySend')"
  93. asyncChange
  94. ></u-switch>
  95. </view>
  96. <view class="flex" v-if="form.isRegularlySend == 0 ? false : true" @click="timeShow = true">
  97. <u-input
  98. v-model="form.timingTime"
  99. placeholder="请选择时间"
  100. placeholderStyle="color:#909399;font-size:12px"
  101. suffixIcon="arrow-right"
  102. suffixIconStyle="color:#909399;font-size:12px;width:10px"
  103. border="none"
  104. style="padding: 0px; margin: 10px 0"
  105. @change="realTimeSaving()"
  106. disabledColor="transparent"
  107. disabled
  108. />
  109. </view>
  110. </view>
  111. </view>
  112. <view class="app-button">
  113. <view class="app-button-padding"></view>
  114. <view class="app-button-fixed">
  115. <u-button class="app-buttom" type="primary" @click="handleSubmit('提交')" shape="circle"> 提交 </u-button>
  116. </view>
  117. </view>
  118. <u-datetime-picker :show="timeShow" v-model="timeValue" mode="datetime" :closeOnClickOverlay="true" @cancel="timeShow = false" @confirm="timeConfirm"></u-datetime-picker>
  119. <u-modal :show="modalShow" title="" :confirmText="'确定'" :cancelText="'取消'" :zoom="false" :showCancelButton="true" @confirm="modalConfirm" @cancel="modalShow = false">
  120. <view class="slot-content" style="max-height: 80vh">
  121. <u-checkbox-group v-model="projectsCheck" placement="row" :size="14" v-if="projectsList.length > 0" style="max-height: 100%; overflow: auto">
  122. <u-checkbox
  123. :customStyle="{ marginBottom: '8px', width: '50%' }"
  124. v-for="(item, index) in projectsList"
  125. :key="index"
  126. :label="item.projectName"
  127. :name="item.id"
  128. :activeColor="proxy.$settingStore.themeColor.color"
  129. >
  130. </u-checkbox>
  131. </u-checkbox-group>
  132. <view v-else>请联系项目管理人员给您分配项目后重试!</view>
  133. </view>
  134. </u-modal>
  135. </template>
  136. <script setup>
  137. /*----------------------------------依赖引入-----------------------------------*/
  138. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  139. import { ref, reactive, computed, getCurrentInstance, toRefs, inject, watchEffect, watch } from "vue";
  140. /*----------------------------------接口引入-----------------------------------*/
  141. import { projectApi } from "@/api/business/project.js";
  142. import { dUserList } from "@/api/system/user.js";
  143. /*----------------------------------组件引入-----------------------------------*/
  144. import avatarList from "../../components/avatarList.vue";
  145. /*----------------------------------store引入-----------------------------------*/
  146. import { systemStores } from "@/store/modules/index";
  147. /*----------------------------------公共方法引入-----------------------------------*/
  148. import { storageSystem } from "@/utils/storage"; // 公共方法引用
  149. /*----------------------------------公共变量-----------------------------------*/
  150. const { proxy } = getCurrentInstance();
  151. const systemStore = systemStores();
  152. const props = defineProps({
  153. projectList: {
  154. type: Object,
  155. default: {},
  156. },
  157. });
  158. /*----------------------------------变量声明-----------------------------------*/
  159. const modal = reactive({
  160. timeShow: false,
  161. timeValue: Number(new Date()),
  162. modalShow: false,
  163. });
  164. const state = reactive({
  165. form: {
  166. reportDate: null,
  167. tomorrowPlan: "",
  168. ccTo: "",
  169. coordinateWork: null,
  170. workContents: [],
  171. sendDingTalk: 1,
  172. isRegularlySend: 0,
  173. timingTime: null,
  174. reportStatus: null,
  175. },
  176. projectsCheck: [],
  177. projectsList: [],
  178. userList: [],
  179. userDate: [],
  180. saveTime: "",
  181. });
  182. const { timeShow, timeValue, modalShow } = toRefs(modal);
  183. const { form, projectsCheck, projectsList, userList, userDate, saveTime } = toRefs(state);
  184. /**
  185. * @初始化
  186. */
  187. function init() {
  188. dUserList({ pageNum: "1", pageSize: "10000" }).then((res) => {
  189. state.userDate = res.data.rows;
  190. });
  191. projectApi()
  192. .ProjectsSelect()
  193. .then((requset) => {
  194. state.projectsList = requset.data;
  195. });
  196. }
  197. /** 时间选择器确定按钮点击事件 */
  198. function timeConfirm(e) {
  199. state.form.timingTime = proxy.$time.getFormatterDate(e.value);
  200. modal.timeShow = false;
  201. }
  202. /** 开关按钮change事件 */
  203. function switchChage(e, key) {
  204. state.form[key] = e == true ? 1 : 0;
  205. if (key === "isRegularlySend") {
  206. state.form.timingTime = null;
  207. }
  208. realTimeSaving();
  209. }
  210. /** 添加人员按钮事件 */
  211. function insertUsers() {
  212. //将人员选中数据传入store中
  213. systemStore.mallList.activeUserList = state.userList;
  214. proxy.$tab.navigateTo(`/pages/business/common/projectMange/mall/index?number=200`);
  215. }
  216. /** 删除人员按钮事件 */
  217. function deleteUsers(index) {
  218. state.userList.splice(index, 1);
  219. realTimeSaving();
  220. }
  221. /** 添加项目按钮事件 */
  222. function insertProjects() {
  223. modal.modalShow = true;
  224. }
  225. /** 实时保存填写数据 */
  226. function realTimeSaving() {
  227. state.saveTime = proxy.$time.formatterDate(new Date(), "hh:mm");
  228. storageSystem.set("project", state);
  229. }
  230. /** 弹窗确定 */
  231. function modalConfirm() {
  232. var newWorkContents = JSON.parse(JSON.stringify(state.form.workContents));
  233. state.form.workContents = [];
  234. state.projectsCheck.forEach((e) => {
  235. state.form.workContents.push({
  236. projectId: e,
  237. projectName: proxy.$common.mapping("projectName", "id", e, state.projectsList),
  238. workTime: "",
  239. workContent: "",
  240. });
  241. });
  242. newWorkContents.forEach((e) => {
  243. state.form.workContents.forEach((f) => {
  244. if (e.projectId == f.projectId) {
  245. f.workTime = e.workTime;
  246. f.workContent = e.workContent;
  247. }
  248. });
  249. });
  250. modal.modalShow = false;
  251. realTimeSaving();
  252. }
  253. /** 提交 */
  254. function handleSubmit() {
  255. state.form.ccTo = state.userList.map((obj) => `${obj.id}`).join(",");
  256. state.form.reportDate = proxy.$time.formatterDate(new Date(), "yyyy-MM-dd");
  257. state.form.workContents.forEach((e) => {
  258. e.workTime = Number(e.workTime);
  259. });
  260. projectApi()
  261. .ReportInsert(state.form)
  262. .then((requset) => {
  263. proxy.$tab.redirectTo("/pages/business/common/projectMange/record/index"); //返回到需要执行方法的页面
  264. state.form.workContents = [];
  265. state.form.tomorrowPlan = "";
  266. state.form.coordinateWork = null;
  267. state.form.isRegularlySend = 0;
  268. state.form.timingTime = null;
  269. storageSystem.set("project", state);
  270. });
  271. }
  272. watch(
  273. () => props.projectList,
  274. (val) => {
  275. state.userList = [];
  276. state.projectsCheck = [];
  277. state.projectsList = [];
  278. Object.keys(props.projectList).forEach((key) => {
  279. state.form[key] = props.projectList[key];
  280. });
  281. state.form.workContents.forEach((e) => {
  282. state.projectsCheck.push(e.projectId);
  283. });
  284. var ccTo = state.form.ccTo.length > 0 ? state.form.ccTo.split(",").map((num) => Number(num)) : [];
  285. state.userDate.forEach((e) => {
  286. if (ccTo.includes(e.userId)) {
  287. state.userList.push({
  288. address: e.address,
  289. avatar: e.avatar,
  290. deptId: e.deptId,
  291. email: e.email,
  292. id: e.userId,
  293. label: e.nickName,
  294. nickName: e.nickName,
  295. phonenumber: e.phonenumber,
  296. post: e.post,
  297. sex: e.sex,
  298. userId: e.userId,
  299. userName: e.userName,
  300. });
  301. }
  302. });
  303. projectApi()
  304. .ProjectsSelect()
  305. .then((requset) => {
  306. state.projectsList = requset.data;
  307. });
  308. storageSystem.set("project", state);
  309. }
  310. );
  311. onReady(() => {});
  312. onShow(() => {
  313. //循环将缓存数据遍历
  314. var storages = storageSystem.get("project");
  315. Object.keys(storages).forEach((key) => {
  316. state[key] = storages[key];
  317. });
  318. //监听组件返回数据
  319. uni.$on("UserMall", function (value) {
  320. state.userList = value;
  321. realTimeSaving();
  322. });
  323. });
  324. onLoad((options) => {
  325. init();
  326. });
  327. onUnload(() => {
  328. uni.$off("UserMall"); //将值删除监听器
  329. });
  330. </script>
  331. <style lang="scss" scoped>
  332. :deep(.u-cell__body) {
  333. color: #000000;
  334. font-size: 12px;
  335. padding: 10px 0px !important;
  336. }
  337. :deep(.u-collapse-item__content) {
  338. overflow: auto;
  339. }
  340. :deep(.u-collapse-item__content__text) {
  341. padding: 0;
  342. }
  343. :deep(.u-cell__left-icon-wrap) {
  344. margin: 0;
  345. }
  346. .content-area {
  347. &-title {
  348. text-align: right;
  349. color: #909399;
  350. }
  351. }
  352. </style>