template1.vue 12 KB

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