template1.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  1. <template>
  2. <view class="content-area">
  3. <view class="content-area-title font12 mtb5 plr10" v-if="!state.form.id">{{ state.form.id }}实时保存,保存时间 {{ 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. border="none"
  27. style="padding: 0px; margin: 10px 0;min-height:100px"
  28. @change="realTimeSaving()"
  29. ></u-textarea>
  30. </u-collapse-item>
  31. </u-collapse>
  32. <u-button class="mt20" type="primary" style="width: 100px; height: 25px" @click="insertProjects()" shape="circle" icon="plus" size="mini"> 添加项目 </u-button>
  33. </view>
  34. <view class="content-area-item mt10 p10 bg-white">
  35. <view class="font14 weight mb10">明日计划</view>
  36. <u-textarea
  37. v-model="form.tomorrowPlan"
  38. placeholder="请输入"
  39. placeholderStyle="color:#909399;font-size:12px"
  40. confirmType="return"
  41. :autoHeight="true"
  42. :maxlength="-1"
  43. :height="'100%'"
  44. border="none"
  45. style="padding: 0px"
  46. @change="realTimeSaving()"
  47. ></u-textarea>
  48. </view>
  49. <view class="content-area-item mt10 p10 bg-white">
  50. <view class="font14 weight mb10">工作协调</view>
  51. <u-textarea
  52. v-model="form.coordinateWork"
  53. placeholder="请输入"
  54. placeholderStyle="color:#909399;font-size:12px"
  55. confirmType="return"
  56. :autoHeight="true"
  57. :maxlength="-1"
  58. :height="'100%'"
  59. border="none"
  60. style="padding: 0px"
  61. @change="realTimeSaving()"
  62. ></u-textarea>
  63. </view>
  64. <view class="content-area-item mt10 p10 bg-white">
  65. <view class="font14 weight mb10">图片上传</view>
  66. <view style="color: #f56c6c; font-size: 11px; margin-bottom: 10px">( 注:不可同步钉钉,最多上传5张 )</view>
  67. <oa-upload :uploadCount="5" :uploadList="reportImage1" :uploadListSrc="'url'" @uploadSuccessChange="uploadSuccessChange" @uploadDeleteChange="uploadDeleteChange"></oa-upload>
  68. </view>
  69. <view class="content-area-item mt10 p10 bg-white">
  70. <view class="font14 weight mb10">附件上传</view>
  71. <view style="color: #f56c6c; font-size: 11px; margin-bottom: 10px">( 注:不可同步钉钉,最多上传5个 )</view>
  72. <uni-file-picker
  73. limit="5"
  74. @select="selectUpload"
  75. v-model="reportFile1"
  76. :auto-upload="false"
  77. file-extname="git,pdf,docx,doc,xls,xlsx,ppt,pptx,txt,zip,rar,7z,gz,bz2,tar,tgz,tbz,txz,apk,ipa,mp3,mp4,avi,flv,rmvb,wmv,mkv,mov,wma,aac,m4a,amr,ogg,flac,wav,amr,ape,m4r,aac,ac3,dts,m4b,m4p,m4v,mp2,mpe,mpeg,mpg,mpv,ogv,rm,swf,vob,wmv,3gp,3g2,asf,asx,avi,flv,m2ts,m4v,mkv,mov,mp4,mpg,mpeg,rm,swf,vob,wmv,3gp,3g2,asf,asx,avi,"
  78. file-mediatype="all"
  79. >
  80. </uni-file-picker>
  81. <!-- 文件列表回显 -->
  82. <br />
  83. <view v-for="(file, index) in reportFile1" :key="index" style="border-bottom: 1px solid #eee; margin: 6px; padding: 6px; font-size: 12px">
  84. <uni-link :href="file.url" text="file.url">{{ file.name }}</uni-link>
  85. <uni-icons type="closeempty" size="12" style="float: right" @click="delectFile(file)"></uni-icons>
  86. </view>
  87. </view>
  88. <view class="content-area-item mt10 p10 bg-white">
  89. <view class="font14 weight mb10">抄送到人</view>
  90. <avatarList :userList="userList" @deleteUsers="deleteUsers" />
  91. <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>
  92. </view>
  93. <view class="content-area-item mt10 p10 bg-white">
  94. <view class="flex">
  95. <view class="font14 weight">同步钉钉</view>
  96. <u-switch
  97. style="margin-left: auto"
  98. :modelValue="form.sendDingTalk == 0 ? false : true"
  99. :ctiveColor="proxy.$settingStore.themeColor.color"
  100. size="20"
  101. :disabled="form.reportStatus == 1"
  102. @change="(event) => switchChage(event, 'sendDingTalk')"
  103. asyncChange
  104. ></u-switch>
  105. </view>
  106. <view class="flex"> </view>
  107. </view>
  108. <view class="content-area-item mt10 p10 bg-white" v-if="form.reportStatus != 1">
  109. <view class="flex">
  110. <view class="font14 weight">定时发送</view>
  111. <u-switch
  112. style="margin-left: auto"
  113. :modelValue="form.isRegularlySend == 0 ? false : true"
  114. :ctiveColor="proxy.$settingStore.themeColor.color"
  115. size="20"
  116. @change="(event) => switchChage(event, 'isRegularlySend')"
  117. asyncChange
  118. ></u-switch>
  119. </view>
  120. <view class="flex" v-if="form.isRegularlySend == 0 ? false : true" @click="timeShow = true">
  121. <u-input
  122. v-model="form.timingTime"
  123. placeholder="请选择时间"
  124. placeholderStyle="color:#909399;font-size:12px"
  125. suffixIcon="arrow-right"
  126. suffixIconStyle="color:#909399;font-size:12px;width:10px"
  127. border="none"
  128. style="padding: 0px; margin: 10px 0"
  129. @change="realTimeSaving()"
  130. disabledColor="transparent"
  131. disabled
  132. />
  133. </view>
  134. </view>
  135. </view>
  136. <view class="app-button">
  137. <view class="app-button-padding"></view>
  138. <view class="app-button-fixed">
  139. <!-- {{ form }} -->
  140. <u-button class="app-buttom" type="primary" @click="handleSubmit('提交')" shape="circle"> {{ form.isRegularlySend == 1 && form.reportStatus != 1 ? "保 存" : "确 定" }} </u-button>
  141. </view>
  142. </view>
  143. <u-datetime-picker :show="timeShow" v-model="timeValue" mode="datetime" :closeOnClickOverlay="true" @cancel="timeShow = false" @confirm="timeConfirm"></u-datetime-picker>
  144. <u-modal :show="modalShow" title="" :confirmText="'确定'" :cancelText="'取消'" :zoom="false" :showCancelButton="true" @confirm="modalConfirm" @cancel="modalShow = false" :picker-options="pickerOptions">
  145. <view class="slot-content" style="max-height: 45vh; overflow: scroll !important;">
  146. <view v-if="projectsList.length > 0" >
  147. <scroll-view scroll-y style="height: 100%; max-height: 300px;">
  148. <u-checkbox-group v-model="projectsCheck" placement="row" :size="14" >
  149. <view class="checkbox-group-title">最近使用</view>
  150. <block v-for="(item, index) in projectsList" >
  151. <u-checkbox
  152. v-if="item.submissions > 0"
  153. :customStyle="{ marginBottom: '8px', width: '50%' }"
  154. :label="item.projectName + ' (' + item.submissions + '次)'"
  155. :name="item.id"
  156. :activeColor="proxy.$settingStore.themeColor.color"
  157. >
  158. </u-checkbox>
  159. </block>
  160. <u-line class="u-line" color="info" style="margin: 10px 0"></u-line>
  161. <view class="checkbox-group-title">其他</view>
  162. <block v-for="(item, index) in projectsList">
  163. <u-checkbox v-if="!item.submissions" :customStyle="{ marginBottom: '8px', width: '50%' }" :label="item.projectName" :name="item.id" :activeColor="proxy.$settingStore.themeColor.color">
  164. </u-checkbox>
  165. </block>
  166. </u-checkbox-group>
  167. </scroll-view>
  168. <!-- <u-checkbox-group v-else v-model="projectsCheck" placement="row" :size="14" style="max-height: 100%; overflow: auto">
  169. <u-checkbox
  170. :customStyle="{ marginBottom: '8px', width: '50%' }"
  171. v-for="(item, index) in projectsList"
  172. :key="index"
  173. :label="item.projectName"
  174. :name="item.id"
  175. :activeColor="proxy.$settingStore.themeColor.color"
  176. >
  177. </u-checkbox>
  178. </u-checkbox-group> -->
  179. </view>
  180. <view v-else>暂未添加项目,请点击确定前往“项目列表”,成为项目成员。</view>
  181. </view>
  182. </u-modal>
  183. </template>
  184. <script setup>
  185. /*----------------------------------依赖引入-----------------------------------*/
  186. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  187. import { ref, reactive, computed, getCurrentInstance, toRefs, inject, watchEffect, watch } from "vue";
  188. /*----------------------------------接口引入-----------------------------------*/
  189. import { projectApi } from "@/api/business/project.js";
  190. import { dUserList } from "@/api/system/user.js";
  191. /*----------------------------------组件引入-----------------------------------*/
  192. import avatarList from "../../components/avatarList.vue";
  193. /*----------------------------------store引入-----------------------------------*/
  194. import { systemStores } from "@/store/modules/index";
  195. /*----------------------------------公共方法引入-----------------------------------*/
  196. import { storageSystem } from "@/utils/storage"; // 公共方法引用
  197. import config from "@/config";
  198. import dayjs from "dayjs";
  199. /*----------------------------------公共变量-----------------------------------*/
  200. const { proxy } = getCurrentInstance();
  201. const systemStore = systemStores();
  202. const props = defineProps({
  203. projectList: {
  204. type: Object,
  205. default: {},
  206. },
  207. });
  208. /*----------------------------------变量声明-----------------------------------*/
  209. const modal = reactive({
  210. timeShow: false,
  211. timeValue: Number(new Date()),
  212. modalShow: false,
  213. });
  214. const state = reactive({
  215. form: {
  216. reportDate: null,
  217. tomorrowPlan: "",
  218. ccTo: "",
  219. coordinateWork: null,
  220. workContents: [],
  221. sendDingTalk: 1,
  222. isRegularlySend: 0,
  223. timingTime: null,
  224. reportImage: [],
  225. reportFile: [],
  226. },
  227. projectsCheck: [],
  228. projectsList: [],
  229. userList: [],
  230. userDate: [],
  231. saveTime: "",
  232. });
  233. const reportImage1 = ref([]); //图片
  234. const reportFile1 = ref([]); //附件
  235. const { timeShow, timeValue, modalShow } = toRefs(modal);
  236. const { form, projectsCheck, projectsList, userList, userDate, saveTime } = toRefs(state);
  237. const disabledDate = (time) => time > Date.now();
  238. /**
  239. * @初始化
  240. */
  241. function init() {
  242. // dUserList().then((res) => {
  243. // state.userDate = res.data;
  244. // });
  245. }
  246. /** 时间选择器确定按钮点击事件 */
  247. function timeConfirm(e) {
  248. const currentTime = dayjs().unix() * 1000; //当前时间戳
  249. const tomorrowZeroPoint = dayjs(dayjs().add(1, 'day').format('YYYY-MM-DD') + " 00:00:00").valueOf(); //第二日零点时间戳
  250. if(e.value < tomorrowZeroPoint && e.value > currentTime){
  251. state.form.timingTime = proxy.$time.getFormatterDate(e.value);
  252. modal.timeShow = false;
  253. }else if(e.value > tomorrowZeroPoint){
  254. proxy.$modal.msg("请选择当天时间!");
  255. }else if(e.value < currentTime){
  256. proxy.$modal.msg("选择时间要大约当前时间!");
  257. }
  258. }
  259. /** 开关按钮change事件 */
  260. function switchChage(e, key) {
  261. state.form[key] = e == true ? 1 : 0;
  262. if (key === "isRegularlySend") {
  263. state.form.timingTime = null;
  264. }
  265. realTimeSaving();
  266. }
  267. /** 添加人员按钮事件 */
  268. function insertUsers() {
  269. proxy.$tab.navigateTo(`/pages/business/common/projectMange/mall/index?number=200&title=选择抄送人`).then(() => {
  270. setTimeout(() => {
  271. uni.$emit("FathertuSon__UserMall", state.userList); //将值存储监听器
  272. }, 500);
  273. });
  274. }
  275. /** 删除人员按钮事件 */
  276. function deleteUsers(index) {
  277. if (state.form.reportStatus == 1) {
  278. console.log("已发送不可修改抄送人");
  279. return;
  280. }
  281. state.userList.splice(index, 1);
  282. realTimeSaving();
  283. }
  284. /** 添加项目按钮事件 */
  285. function insertProjects() {
  286. modal.modalShow = true;
  287. projectApi()
  288. .ProjectsSelect()
  289. .then((requset) => {
  290. state.projectsList = requset.data;
  291. });
  292. }
  293. /** 实时保存填写数据 */
  294. function realTimeSaving() {
  295. if (!state.form.id) {
  296. state.saveTime = proxy.$time.formatterDate(new Date(), "hh:mm");
  297. storageSystem.set("project", state);
  298. }
  299. }
  300. /** 弹窗确定 */
  301. function modalConfirm() {
  302. if(projectsList.value.length){
  303. var newWorkContents = JSON.parse(JSON.stringify(state.form.workContents));
  304. state.form.workContents = [];
  305. state.projectsCheck.forEach((e) => {
  306. state.form.workContents.push({
  307. projectId: e,
  308. projectName: proxy.$common.mapping("projectName", "id", e, state.projectsList),
  309. workTime: "",
  310. workContent: "",
  311. });
  312. });
  313. newWorkContents.forEach((e) => {
  314. state.form.workContents.forEach((f) => {
  315. if (e.projectId == f.projectId) {
  316. f.workTime = e.workTime;
  317. f.workContent = e.workContent;
  318. }
  319. });
  320. });
  321. modal.modalShow = false;
  322. }else{
  323. modal.modalShow = false;
  324. proxy.$tab.redirectTo("/pages/business/common/projectMange/list/index");
  325. }
  326. // realTimeSaving();
  327. }
  328. /**
  329. * @图片上传成功回调
  330. */
  331. function uploadSuccessChange(e) {
  332. reportImage1.value.push({
  333. name: e.name,
  334. url: e.url,
  335. });
  336. reportImage1.value = reportImage1.value.slice(0, 5);
  337. realTimeSaving();
  338. }
  339. /**
  340. * @图片删除回调
  341. */
  342. function uploadDeleteChange(e) {
  343. reportImage1.value = e;
  344. realTimeSaving();
  345. }
  346. /**
  347. * @文件删除
  348. */
  349. function delectFile(param) {
  350. reportFile1.value = reportFile1.value.filter(function (item) {
  351. return item.name != param.name;
  352. });
  353. realTimeSaving();
  354. }
  355. /**
  356. * @文件上传
  357. */
  358. function selectUpload(e) {
  359. // console.log('上传:', e)
  360. e.tempFilePaths.forEach((item, index) => {
  361. uni.uploadFile({
  362. url: config.baseUrl + "/service-file/upload",
  363. filePath: item,
  364. name: "file",
  365. success: (uploadFileRes) => {
  366. reportFile1.value.push(JSON.parse(uploadFileRes.data).data);
  367. realTimeSaving();
  368. },
  369. fail: (err) => {
  370. console.log(err);
  371. },
  372. });
  373. });
  374. }
  375. // function delectUpload(e){
  376. // console.log(e)
  377. // }
  378. // function uploadSuccess(e) {
  379. // console.log('上传成功', e)
  380. // }
  381. // function uploadFail(e) {
  382. // console.log('上传失败:', e)
  383. // }
  384. /** 提交 */
  385. function handleSubmit() {
  386. state.form.sendDingTalk == true ? 1 : 0;
  387. state.form.id = state.form.id ? Number(state.form.id) : "";
  388. state.form.ccTo = state.userList.map((obj) => `${obj.id}`).join(",");
  389. state.form.reportDate = proxy.$time.formatterDate(new Date(), "yyyy-MM-dd");
  390. state.form.workContents.forEach((e) => {
  391. e.workTime = Number(e.workTime);
  392. });
  393. state.form.reportImage = JSON.stringify(reportImage1.value);
  394. state.form.reportFile = JSON.stringify(reportFile1.value);
  395. projectApi()
  396. .ReportInsert(state.form)
  397. .then((requset) => {
  398. proxy.$tab.redirectTo("/pages/business/common/projectMange/record/index"); //返回到需要执行方法的页面
  399. // storageSystem.set("project", state);
  400. })
  401. .catch((err) => {});
  402. }
  403. watch(
  404. () => reportFile1.value.length,
  405. (val) => {
  406. var element = document.querySelector(".files-button");
  407. if (reportFile1.value.length >= 5) {
  408. element.style.display = "none";
  409. } else {
  410. element.style.display = "block";
  411. }
  412. }
  413. );
  414. watch(
  415. () => props.projectList,
  416. (val) => {
  417. state.userList = [];
  418. state.projectsCheck = [];
  419. state.projectsList = [];
  420. state.form.reportImage = [];
  421. state.form.reportFile = [];
  422. Object.keys(props.projectList).forEach((key) => {
  423. state.form[key] = props.projectList[key];
  424. });
  425. reportImage1.value = state.form.reportImage ? JSON.parse(state.form.reportImage) : [];
  426. reportFile1.value = state.form.reportFile ? JSON.parse(state.form.reportFile) : [];
  427. state.form.workContents.forEach((e) => {
  428. state.projectsCheck.push(e.projectId);
  429. });
  430. var ccTo = state.form.ccTo.length > 0 ? state.form.ccTo.split(",").map((num) => Number(num)) : [];
  431. dUserList().then((res) => {
  432. state.userDate = res.data;
  433. state.userDate.forEach((e) => {
  434. if (ccTo.includes(e.userId)) {
  435. state.userList.push({
  436. address: e.address,
  437. avatar: e.avatar,
  438. deptId: e.deptId,
  439. email: e.email,
  440. id: e.userId,
  441. label: e.nickName,
  442. nickName: e.nickName,
  443. phonenumber: e.phonenumber,
  444. post: e.post,
  445. sex: e.sex,
  446. userId: e.userId,
  447. userName: e.userName,
  448. });
  449. }
  450. });
  451. });
  452. if (!state.form.id) {
  453. storageSystem.set("project", state);
  454. }
  455. }
  456. );
  457. onReady(() => {});
  458. onShow(() => {
  459. init();
  460. //循环将缓存数据遍历
  461. if (!state.form.id) {
  462. var storages = storageSystem.get("project");
  463. Object.keys(storages).forEach((key) => {
  464. state[key] = storages[key];
  465. });
  466. }
  467. // 监听组件返回数据
  468. uni.$on("SontoFather__UserMall", function (value) {
  469. state.userList = value;
  470. if (!state.form.id) {
  471. realTimeSaving();
  472. }
  473. });
  474. });
  475. onLoad((options) => {
  476. if (options.id) {
  477. state.form.id = options.id;
  478. } else {
  479. state.form.id = "";
  480. }
  481. });
  482. onUnload(() => {
  483. uni.$off("SontoFather__UserMall"); //将值删除监听器
  484. });
  485. </script>
  486. <style lang="scss">
  487. :deep(.uni-file-picker__lists, .is-text-box) {
  488. display: none !important;
  489. opacity: 0 !important;
  490. height: 0 !important;
  491. }
  492. </style>
  493. <style lang="scss" scoped>
  494. .checkbox-group-title {
  495. display: block;
  496. width: 100%;
  497. font-size: 16px;
  498. font-weight: bold;
  499. note-color: #909399;
  500. margin-bottom: 10px;
  501. }
  502. :deep() {
  503. .u-cell__body {
  504. color: #000000;
  505. font-size: 12px;
  506. padding: 10px 0px !important;
  507. }
  508. .u-collapse-item__content {
  509. overflow: auto;
  510. }
  511. .u-collapse-item__content__text {
  512. padding: 0;
  513. }
  514. .u-cell__left-icon-wrap {
  515. margin: 0;
  516. }
  517. }
  518. .content-area {
  519. &-title {
  520. text-align: right;
  521. color: #909399;
  522. }
  523. }
  524. </style>