template1.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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="timeShow = true">
  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, watchEffect } from "vue";
  164. /*----------------------------------接口引入-----------------------------------*/
  165. import { projectApi } from "@/api/business/project.js";
  166. import { UserList } from "@/api/system/user.js";
  167. /*----------------------------------组件引入-----------------------------------*/
  168. /*----------------------------------store引入-----------------------------------*/
  169. /*----------------------------------公共方法引入-----------------------------------*/
  170. import { storageSystem } from "@/utils/storage"; // 公共方法引用
  171. /*----------------------------------公共变量-----------------------------------*/
  172. const { proxy } = getCurrentInstance();
  173. const props = defineProps({
  174. projectList: {
  175. type: Object,
  176. default: {},
  177. },
  178. });
  179. /*----------------------------------变量声明-----------------------------------*/
  180. const state = reactive({
  181. timeShow: false,
  182. timeValue: Number(new Date()),
  183. modalShow: false,
  184. form: {
  185. reportDate: null,
  186. tomorrowPlan: "",
  187. ccTo: "",
  188. coordinateWork: null,
  189. workContents: [],
  190. sendDingTalk: 1,
  191. isRegularlySend: 0,
  192. timingTime: null,
  193. reportStatus: null,
  194. },
  195. projectsCheck: [],
  196. projectsList: [],
  197. userList: [],
  198. userDate: [],
  199. saveTime: "",
  200. });
  201. const { timeShow, timeValue, modalShow, form, projectsCheck, projectsList, userList, userDate, saveTime } = toRefs(state);
  202. /**
  203. * @初始化
  204. */
  205. function init() {
  206. UserList({ pageNum: "1", pageSize: "10000" }).then((res) => {
  207. state.userDate = res.data.rows;
  208. });
  209. projectApi()
  210. .ProjectsSelect()
  211. .then((requset) => {
  212. state.projectsList = requset.data;
  213. });
  214. }
  215. /** 时间选择器确定按钮点击事件 */
  216. function timeConfirm() {
  217. state.form.timingTime = proxy.$time.getFormatterDate(state.timeValue);
  218. state.timeShow = false;
  219. }
  220. /** 开关按钮change事件 */
  221. function switchChage(e, key) {
  222. state.form[key] = e == true ? 1 : 0;
  223. if (key === "isRegularlySend") {
  224. state.form.timingTime = null;
  225. }
  226. realTimeSaving();
  227. }
  228. /** 添加人员按钮事件 */
  229. function insertUsers() {
  230. proxy.$tab.navigateTo(`/pages/business/common/projectMange/mall/index`);
  231. }
  232. /** 删除人员按钮事件 */
  233. function deleteUsers(index) {
  234. state.userList.splice(index, 1);
  235. realTimeSaving();
  236. }
  237. /** 添加项目按钮事件 */
  238. function insertProjects() {
  239. state.modalShow = true;
  240. }
  241. /** 实时保存填写数据 */
  242. function realTimeSaving() {
  243. state.saveTime = proxy.$time.formatterDate(new Date(), "hh:mm");
  244. storageSystem.set("project", state);
  245. }
  246. /** 弹窗确定 */
  247. function modalConfirm() {
  248. var newWorkContents = JSON.parse(JSON.stringify(state.form.workContents));
  249. state.form.workContents = [];
  250. state.projectsCheck.forEach((e) => {
  251. state.form.workContents.push({
  252. projectId: e,
  253. projectName: proxy.$common.mapping("projectName", "id", e, state.projectsList),
  254. workTime: "",
  255. workContent: "",
  256. });
  257. });
  258. newWorkContents.forEach((e) => {
  259. state.form.workContents.forEach((f) => {
  260. if (e.projectId == f.projectId) {
  261. f.workTime = e.workTime;
  262. f.workContent = e.workContent;
  263. }
  264. });
  265. });
  266. state.modalShow = false;
  267. realTimeSaving();
  268. }
  269. /** 提交 */
  270. function handleSubmit() {
  271. if (!state.form.tomorrowPlan) {
  272. proxy.$modal.showToast("请输入明日计划");
  273. }
  274. state.form.ccTo = state.userList.map((obj) => `${obj.id}`).join(",");
  275. state.form.reportDate = proxy.$time.formatterDate(new Date(), "yyyy-MM-dd");
  276. state.form.workContents.forEach((e) => {
  277. e.workTime = parseInt(e.workTime);
  278. });
  279. projectApi()
  280. .ReportInsert(state.form)
  281. .then((requset) => {
  282. proxy.$tab.redirectTo("/pages/business/common/projectMange/record/index"); //返回到需要执行方法的页面
  283. state.form.workContents = [];
  284. state.form.tomorrowPlan = "";
  285. state.form.coordinateWork = null;
  286. state.form.isRegularlySend = 0;
  287. state.form.timingTime = null;
  288. storageSystem.set("project", state);
  289. });
  290. }
  291. watchEffect(() => {
  292. if (JSON.stringify(props.projectList) != "{}") {
  293. state.userList = [];
  294. state.projectsCheck = [];
  295. Object.keys(props.projectList).forEach((key) => {
  296. state.form[key] = props.projectList[key];
  297. });
  298. var ccTo = state.form.ccTo.length > 0 ? state.form.ccTo.split(",").map((num) => Number(num)) : [];
  299. state.userDate.forEach((e) => {
  300. if (ccTo.includes(e.userId)) {
  301. state.userList.push({
  302. address: e.address,
  303. avatar: e.avatar,
  304. deptId: e.deptId,
  305. email: e.email,
  306. id: e.userId,
  307. label: e.nickName,
  308. nickName: e.nickName,
  309. phonenumber: e.phonenumber,
  310. post: e.post,
  311. sex: e.sex,
  312. userId: e.userId,
  313. userName: e.userName,
  314. });
  315. }
  316. });
  317. state.form.workContents.forEach((e) => {
  318. state.projectsCheck.push(e.projectId);
  319. });
  320. storageSystem.set("project", state);
  321. }
  322. });
  323. onReady(() => {});
  324. onShow(() => {
  325. //循环将缓存数据遍历
  326. var storages = storageSystem.get("project");
  327. Object.keys(storages).forEach((key) => {
  328. state[key] = storages[key];
  329. });
  330. //监听组件返回数据
  331. uni.$on("UserMall", function (value) {
  332. state.userList = value;
  333. realTimeSaving();
  334. });
  335. });
  336. onLoad((options) => {
  337. init();
  338. });
  339. onUnload(() => {
  340. uni.$off("UserMall"); //将值删除监听器
  341. });
  342. </script>
  343. <style lang="scss" scoped>
  344. :deep(.u-cell__body) {
  345. color: #000000;
  346. font-size: 12px;
  347. padding: 10px 0px !important;
  348. }
  349. :deep(.u-collapse-item__content) {
  350. overflow: auto;
  351. }
  352. :deep(.u-collapse-item__content__text) {
  353. padding: 0;
  354. }
  355. :deep(.u-cell__left-icon-wrap) {
  356. margin: 0;
  357. }
  358. .content-area {
  359. &-title {
  360. text-align: right;
  361. color: #909399;
  362. }
  363. &-item {
  364. &-avatar {
  365. position: relative;
  366. &::after {
  367. position: absolute;
  368. content: "✖";
  369. display: inline-block;
  370. padding: 2px 4px;
  371. border-radius: 100%;
  372. cursor: pointer;
  373. font-size: 8px;
  374. text-align: center;
  375. background-color: #ccc;
  376. color: #fff;
  377. top: -5px;
  378. right: -5px;
  379. }
  380. &::after:hover {
  381. background-color: #ccc;
  382. }
  383. }
  384. }
  385. }
  386. </style>