template1.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  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. :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. <view style="color:#f56c6c;font-size:11px;margin-bottom:10px">( 注:不可同步钉钉,最多上传5张 )</view>
  68. <oaUpload :uploadCount="5" :uploadList="reportImage1" :uploadListSrc="'url'" @uploadSuccessChange="uploadSuccessChange" @uploadDeleteChange="uploadDeleteChange"></oaUpload>
  69. </view>
  70. <view class="content-area-item mt10 p10 bg-white">
  71. <view class="font14 weight mb10">附件上传</view>
  72. <view style="color:#f56c6c;font-size:11px;margin-bottom:10px">( 注:不可同步钉钉,最多上传5个 )</view>
  73. <uni-file-picker 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">
  145. <view class="slot-content" style="max-height: 45vh;overflow:auto">
  146. <view v-if="projectsList.length > 0">
  147. <u-checkbox-group v-model="projectsCheck" placement="row" :size="14" style="max-height: 100%; overflow: auto">
  148. <view class="checkbox-group-title">最近使用</view>
  149. <block v-for="(item, index) in projectsList">
  150. <u-checkbox v-if="item.submissions>0"
  151. :customStyle="{ marginBottom: '8px', width: '50%' }"
  152. :label="item.projectName+' ('+item.submissions+'次)'"
  153. :name="item.id"
  154. :activeColor="proxy.$settingStore.themeColor.color"
  155. >
  156. </u-checkbox>
  157. </block>
  158. <u-line class="u-line" color="info" style="margin:10px 0"></u-line>
  159. <view class="checkbox-group-title">其他</view>
  160. <block v-for="(item, index) in projectsList">
  161. <u-checkbox v-if="!item.submissions"
  162. :customStyle="{ marginBottom: '8px', width: '50%' }"
  163. :label="item.projectName"
  164. :name="item.id"
  165. :activeColor="proxy.$settingStore.themeColor.color"
  166. >
  167. </u-checkbox>
  168. </block>
  169. </u-checkbox-group>
  170. <!-- <u-checkbox-group v-else v-model="projectsCheck" placement="row" :size="14" style="max-height: 100%; overflow: auto">
  171. <u-checkbox
  172. :customStyle="{ marginBottom: '8px', width: '50%' }"
  173. v-for="(item, index) in projectsList"
  174. :key="index"
  175. :label="item.projectName"
  176. :name="item.id"
  177. :activeColor="proxy.$settingStore.themeColor.color"
  178. >
  179. </u-checkbox>
  180. </u-checkbox-group> -->
  181. </view>
  182. <view v-else>请联系项目管理人员给您分配项目后重试!</view>
  183. </view>
  184. </u-modal>
  185. </template>
  186. <script setup>
  187. /*----------------------------------依赖引入-----------------------------------*/
  188. import { onLoad, onShow, onReady, onHide, onLaunch, onUnload, onNavigationBarButtonTap, onPageScroll } from "@dcloudio/uni-app";
  189. import { ref, reactive, computed, getCurrentInstance, toRefs, inject, watchEffect, watch } from "vue";
  190. /*----------------------------------接口引入-----------------------------------*/
  191. import { projectApi } from "@/api/business/project.js";
  192. import { dUserList } from "@/api/system/user.js";
  193. /*----------------------------------组件引入-----------------------------------*/
  194. import avatarList from "../../components/avatarList.vue";
  195. import oaUpload from "@/components/oa-upload/index"
  196. /*----------------------------------store引入-----------------------------------*/
  197. import { systemStores } from "@/store/modules/index";
  198. /*----------------------------------公共方法引入-----------------------------------*/
  199. import { storageSystem } from "@/utils/storage"; // 公共方法引用
  200. import config from "@/config";
  201. /*----------------------------------公共变量-----------------------------------*/
  202. const { proxy } = getCurrentInstance();
  203. const systemStore = systemStores();
  204. const props = defineProps({
  205. projectList: {
  206. type: Object,
  207. default: {},
  208. },
  209. });
  210. /*----------------------------------变量声明-----------------------------------*/
  211. const modal = reactive({
  212. timeShow: false,
  213. timeValue: Number(new Date()),
  214. modalShow: false,
  215. });
  216. const state = reactive({
  217. form: {
  218. reportDate: null,
  219. tomorrowPlan: "",
  220. ccTo: "",
  221. coordinateWork: null,
  222. workContents: [],
  223. sendDingTalk: 1,
  224. isRegularlySend: 0,
  225. timingTime: null,
  226. reportImage: [],
  227. reportFile: [],
  228. },
  229. projectsCheck: [],
  230. projectsList: [],
  231. userList: [],
  232. userDate: [],
  233. saveTime: "",
  234. });
  235. const reportImage1=ref([])//图片
  236. const reportFile1=ref([])//附件
  237. const { timeShow, timeValue, modalShow } = toRefs(modal);
  238. const { form, projectsCheck, projectsList, userList, userDate, saveTime } = toRefs(state);
  239. /**
  240. * @初始化
  241. */
  242. function init() {
  243. dUserList().then((res) => {
  244. state.userDate = res.data;
  245. });
  246. }
  247. /** 时间选择器确定按钮点击事件 */
  248. function timeConfirm(e) {
  249. state.form.timingTime = proxy.$time.getFormatterDate(e.value);
  250. modal.timeShow = false;
  251. }
  252. /** 开关按钮change事件 */
  253. function switchChage(e, key) {
  254. state.form[key] = e == true ? 1 : 0;
  255. if (key === "isRegularlySend") {
  256. state.form.timingTime = null;
  257. }
  258. realTimeSaving();
  259. }
  260. /** 添加人员按钮事件 */
  261. function insertUsers() {
  262. //将人员选中数据传入store中
  263. systemStore.mallList.activeUserList = state.userList;
  264. proxy.$tab.navigateTo(`/pages/business/common/projectMange/mall/index?number=200&type=3`);
  265. }
  266. /** 删除人员按钮事件 */
  267. function deleteUsers(index) {
  268. if (state.form.reportStatus == 1) {
  269. console.log("已发送不可修改抄送人");
  270. return;
  271. }
  272. state.userList.splice(index, 1);
  273. realTimeSaving();
  274. }
  275. /** 添加项目按钮事件 */
  276. function insertProjects() {
  277. modal.modalShow = true;
  278. projectApi()
  279. .ProjectsSelect()
  280. .then((requset) => {
  281. state.projectsList = requset.data;
  282. });
  283. }
  284. /** 实时保存填写数据 */
  285. function realTimeSaving() {
  286. if(!state.form.id){
  287. state.saveTime = proxy.$time.formatterDate(new Date(), "hh:mm");
  288. storageSystem.set("project", state);
  289. }
  290. }
  291. /** 弹窗确定 */
  292. function modalConfirm() {
  293. var newWorkContents = JSON.parse(JSON.stringify(state.form.workContents));
  294. state.form.workContents = [];
  295. state.projectsCheck.forEach((e) => {
  296. state.form.workContents.push({
  297. projectId: e,
  298. projectName: proxy.$common.mapping("projectName", "id", e, state.projectsList),
  299. workTime: "",
  300. workContent: "",
  301. });
  302. });
  303. newWorkContents.forEach((e) => {
  304. state.form.workContents.forEach((f) => {
  305. if (e.projectId == f.projectId) {
  306. f.workTime = e.workTime;
  307. f.workContent = e.workContent;
  308. }
  309. });
  310. });
  311. modal.modalShow = false;
  312. // realTimeSaving();
  313. }
  314. /**
  315. * @图片上传成功回调
  316. */
  317. function uploadSuccessChange(e) {
  318. reportImage1.value.push({
  319. name: e.name,
  320. url: e.url,
  321. })
  322. reportImage1.value=reportImage1.value.slice(0,5)
  323. realTimeSaving()
  324. }
  325. /**
  326. * @图片删除回调
  327. */
  328. function uploadDeleteChange(e) {
  329. reportImage1.value = e;
  330. realTimeSaving()
  331. }
  332. /**
  333. * @文件删除
  334. */
  335. function delectFile(param){
  336. reportFile1.value = reportFile1.value.filter(function (item) {
  337. return item.name!=param.name;
  338. });
  339. realTimeSaving()
  340. }
  341. /**
  342. * @文件上传
  343. */
  344. function selectUpload(e) {
  345. // console.log('上传:', e)
  346. e.tempFilePaths.forEach((item,index) => {
  347. uni.uploadFile({
  348. url: config.baseUrl+'/service-file/upload',
  349. filePath: item,
  350. name: 'file',
  351. success: (uploadFileRes) => {
  352. reportFile1.value.push(JSON.parse(uploadFileRes.data).data)
  353. realTimeSaving()
  354. },
  355. fail: (err) => {
  356. console.log(err);
  357. }
  358. })
  359. })
  360. }
  361. // function delectUpload(e){
  362. // console.log(e)
  363. // }
  364. // function uploadSuccess(e) {
  365. // console.log('上传成功', e)
  366. // }
  367. // function uploadFail(e) {
  368. // console.log('上传失败:', e)
  369. // }
  370. /** 提交 */
  371. function handleSubmit() {
  372. state.form.sendDingTalk == true ? 1 : 0;
  373. state.form.id = state.form.id ? Number(state.form.id) : "";
  374. state.form.ccTo = state.userList.map((obj) => `${obj.id}`).join(",");
  375. state.form.reportDate = proxy.$time.formatterDate(new Date(), "yyyy-MM-dd");
  376. state.form.workContents.forEach((e) => {
  377. e.workTime = Number(e.workTime);
  378. });
  379. state.form.reportImage=JSON.stringify(reportImage1.value);
  380. state.form.reportFile=JSON.stringify(reportFile1.value);
  381. projectApi()
  382. .ReportInsert(state.form)
  383. .then((requset) => {
  384. proxy.$tab.redirectTo("/pages/business/common/projectMange/record/index"); //返回到需要执行方法的页面
  385. // storageSystem.set("project", state);
  386. }).catch((err) => {
  387. });;
  388. }
  389. watch(
  390. () => reportFile1.value.length,
  391. (val) => {
  392. var element = document.querySelector('.files-button');
  393. if(reportFile1.value.length>=5){
  394. element.style.display = 'none';
  395. }else{
  396. element.style.display = 'block';
  397. }
  398. }
  399. );
  400. watch(
  401. () => props.projectList,
  402. (val) => {
  403. state.userList = [];
  404. state.projectsCheck = [];
  405. state.projectsList = [];
  406. state.form.reportImage = [];
  407. state.form.reportFile = [];
  408. Object.keys(props.projectList).forEach((key) => {
  409. state.form[key] = props.projectList[key];
  410. });
  411. reportImage1.value=state.form.reportImage?JSON.parse(state.form.reportImage):[];
  412. reportFile1.value=state.form.reportFile?JSON.parse(state.form.reportFile):[];
  413. state.form.workContents.forEach((e) => {
  414. state.projectsCheck.push(e.projectId);
  415. });
  416. var ccTo = state.form.ccTo.length > 0 ? state.form.ccTo.split(",").map((num) => Number(num)) : [];
  417. // setTimeout(function () {
  418. state.userDate.forEach((e) => {
  419. if (ccTo.includes(e.userId)) {
  420. state.userList.push({
  421. address: e.address,
  422. avatar: e.avatar,
  423. deptId: e.deptId,
  424. email: e.email,
  425. id: e.userId,
  426. label: e.nickName,
  427. nickName: e.nickName,
  428. phonenumber: e.phonenumber,
  429. post: e.post,
  430. sex: e.sex,
  431. userId: e.userId,
  432. userName: e.userName,
  433. });
  434. }
  435. });
  436. // }, 300);
  437. if(!state.form.id){
  438. storageSystem.set("project", state);
  439. }
  440. }
  441. );
  442. onReady(() => {});
  443. onShow(() => {
  444. init();
  445. //循环将缓存数据遍历
  446. if(!state.form.id){
  447. var storages = storageSystem.get("project");
  448. Object.keys(storages).forEach((key) => {
  449. state[key] = storages[key];
  450. });
  451. }
  452. // 监听组件返回数据
  453. uni.$on("UserMall", function (value) {
  454. state.userList = value;
  455. if(!state.form.id){
  456. realTimeSaving();
  457. }
  458. });
  459. });
  460. onLoad((options) => {
  461. if (options.id) {
  462. state.form.id = options.id;
  463. } else {
  464. state.form.id = "";
  465. }
  466. });
  467. onUnload(() => {
  468. uni.$off("UserMall"); //将值删除监听器
  469. });
  470. </script>
  471. <style lang="scss" >
  472. :deep(.uni-file-picker__lists, .is-text-box){
  473. display:none!important;
  474. opacity:0!important;
  475. height:0!important;
  476. }
  477. </style>
  478. <style lang="scss" scoped>
  479. .checkbox-group-title{
  480. display:block;width:100%;
  481. font-size:16px;
  482. font-weight:bold;
  483. note-color: #909399;
  484. margin-bottom:10px;
  485. }
  486. :deep() {
  487. .u-cell__body {
  488. color: #000000;
  489. font-size: 12px;
  490. padding: 10px 0px !important;
  491. }
  492. .u-collapse-item__content {
  493. overflow: auto;
  494. }
  495. .u-collapse-item__content__text {
  496. padding: 0;
  497. }
  498. .u-cell__left-icon-wrap {
  499. margin: 0;
  500. }
  501. }
  502. .content-area {
  503. &-title {
  504. text-align: right;
  505. color: #909399;
  506. }
  507. }
  508. </style>