index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <div class="outer-layer">
  3. <div class="schedule-left">
  4. <div class="title commons-title" style="margin-bottom: 0">我的日程</div>
  5. <div style="margin-top: 16px">
  6. <el-input v-model="sourceList.pagination.keyword" placeholder="请输入关键词" class="input-with-select" clearable>
  7. <template #append>
  8. <el-button :icon="Search" @click="getList" />
  9. </template>
  10. </el-input>
  11. </div>
  12. <div style="margin-top: 16px">
  13. <el-menu :default-active="menuDefault" class="el-menu-vertical-demo" @select="handleSelectMenu">
  14. <el-menu-item :index="1">
  15. <span>我的创建</span>
  16. </el-menu-item>
  17. <el-menu-item :index="2">
  18. <span>全员日程</span>
  19. </el-menu-item>
  20. <el-menu-item :index="3">
  21. <span>我的待办</span>
  22. </el-menu-item>
  23. <el-menu-item :index="4" disabled>
  24. <span>客户明细</span>
  25. </el-menu-item>
  26. </el-menu>
  27. </div>
  28. <div style="margin-top: 16px; font-size: 20px; font-weight: 700">
  29. <span>{{ day }}</span>
  30. <span style="margin-left: 16px">{{ calculationWeek(day, "yyyy年MM月DD日") }}</span>
  31. </div>
  32. </div>
  33. <div class="schedule-right">
  34. <div class="schedule-top">
  35. <el-row>
  36. <el-col :span="10" style="text-align: left">
  37. <el-select v-model="status" style="width: 110px">
  38. <el-option v-for="item in tableStatus" :key="item.value" :label="item.label" :value="item.value" />
  39. </el-select>
  40. <el-button type="info" style="margin-left: 8px" @click="clickToday()" plain>今日</el-button>
  41. </el-col>
  42. <el-col :span="4" style="text-align: center; height: 32px; line-height: 32px">
  43. <div style="display: flex; justify-content: space-between">
  44. <el-button :icon="ArrowLeftBold" @click="prevMonth()" />
  45. <span style="font-weight: 700">{{ month }}</span>
  46. <el-button :icon="ArrowRightBold" @click="nextMonth()" />
  47. </div>
  48. </el-col>
  49. <el-col :span="10" style="text-align: right">
  50. <el-button type="primary" @click="newSchedule()">新建日程</el-button>
  51. </el-col>
  52. </el-row>
  53. </div>
  54. <div class="schedule-bottom">
  55. <el-calendar v-model="date" ref="calendar">
  56. <template #date-cell="{ data }">
  57. <div>
  58. <div :class="'title ' + (data.isSelected ? 'is-selected' : '')" :style="data.isSelected ? ' background-color: #eeeeee;' : ''">
  59. <span :class="data.isSelected ? 'select-title' : ''">{{ data.day.substr(8, 10) }}</span>
  60. <span style="position: absolute; right: 4px; top: 4px; font-size: 14px; color: black">4条</span>
  61. </div>
  62. <div :class="data.isSelected ? 'is-selected' : ''" style="text-align: center; height: 18px; line-height: 18px">
  63. {{ data.day.substr(8, 10) }}
  64. </div>
  65. <div :class="data.isSelected ? 'is-selected' : ''" style="text-align: center; height: 18px; line-height: 18px">
  66. {{ data.day.substr(8, 10) }}
  67. </div>
  68. <div :class="data.isSelected ? 'is-selected' : ''" style="text-align: center; height: 18px; line-height: 18px">
  69. {{ data.day.substr(8, 10) }}
  70. </div>
  71. <div :class="data.isSelected ? 'is-selected' : ''" style="text-align: center; height: 18px; line-height: 18px">
  72. {{ data.day.substr(8, 10) }}
  73. </div>
  74. </div>
  75. </template>
  76. </el-calendar>
  77. </div>
  78. </div>
  79. <el-dialog title="新建日程" v-if="openSchedule" v-model="openSchedule" width="640" v-loading="loadingDialog" :close-on-click-modal="false">
  80. <byForm :formConfig="formConfig" :formOption="formOption" v-model="formData.data" :rules="rules" ref="schedule">
  81. <template #time>
  82. <div style="width: 100%">
  83. <!-- <el-row :gutter="10" style="margin-bottom: 18px"> -->
  84. <el-row :gutter="10">
  85. <el-col :span="11">
  86. <el-form-item prop="startDate">
  87. <el-date-picker
  88. v-model="formData.data.startDate"
  89. type="datetime"
  90. placeholder="请选择开始时间"
  91. value-format="YYYY-MM-DD HH:mm:ss"
  92. style="width: 100%" />
  93. </el-form-item>
  94. </el-col>
  95. <el-col :span="2" style="text-align: center"> 至 </el-col>
  96. <el-col :span="11">
  97. <el-form-item prop="endDate">
  98. <el-date-picker
  99. v-model="formData.data.endDate"
  100. type="datetime"
  101. placeholder="请选择结束时间"
  102. value-format="YYYY-MM-DD HH:mm:ss"
  103. style="width: 100%" />
  104. </el-form-item>
  105. </el-col>
  106. </el-row>
  107. <!-- <el-row :gutter="10" style="margin-bottom: 18px">
  108. <el-col :span="11">
  109. <el-form-item prop="repeatType">
  110. <el-select v-model="formData.data.repeatType" placeholder="请选择重复类型" style="width: 100%">
  111. <el-option v-for="item in repeatType" :key="item.value" :label="item.label" :value="item.value"> </el-option>
  112. </el-select>
  113. </el-form-item>
  114. </el-col>
  115. <el-col :span="13">
  116. <el-checkbox v-model="formData.data.isAllDay" label="全天任务" :true-label="1" :false-label="0" border />
  117. </el-col>
  118. </el-row> -->
  119. </div>
  120. </template>
  121. <template #color>
  122. <div style="width: 100%; display: flex">
  123. <el-radio-group v-model="formData.data.color" class="radio-color">
  124. <el-radio v-for="(item, index) in predefineColors" :key="index" :label="item">
  125. <div :style="'background-color: ' + item">
  126. <el-icon style="color: #fff; font-size: 20px; margin: 2px 0 0 2px" v-if="item === formData.data.color"><Check /></el-icon>
  127. </div>
  128. </el-radio>
  129. </el-radio-group>
  130. </div>
  131. </template>
  132. <template #participantList>
  133. <div style="width: 100%">
  134. <el-select v-model="formData.data.participantList" multiple placeholder="请选择参与人" style="width: 100%">
  135. <el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value" />
  136. </el-select>
  137. <div style="color: #ccc; font-size: 12px">
  138. <span v-if="formData.data.participantList && formData.data.participantList.length > 0">共{{ formData.data.participantList.length }}人参与</span>
  139. <span v-else>共0人参与</span>
  140. </div>
  141. </div>
  142. </template>
  143. <template #noticeType>
  144. <div style="width: 100%">
  145. <el-select v-model="formData.data.noticeType" placeholder="请选择通知" style="width: 100%">
  146. <el-option v-for="item in noticeType" :key="item.value" :label="item.label" :value="item.value" />
  147. </el-select>
  148. </div>
  149. </template>
  150. <!-- <template #taskPermissions>
  151. <div style="width: 100%">
  152. <el-form-item prop="taskPermissions">
  153. <el-radio-group v-model="formData.data.taskPermissions">
  154. <el-radio v-for="item in taskPermissions" :key="item.value" :label="item.value">{{ item.label }}</el-radio>
  155. </el-radio-group>
  156. </el-form-item>
  157. </div>
  158. </template> -->
  159. </byForm>
  160. <template #footer>
  161. <el-button @click="openSchedule = false" size="large">取 消</el-button>
  162. <el-button type="primary" @click="clickSubmit()" size="large">确 定</el-button>
  163. </template>
  164. </el-dialog>
  165. </div>
  166. </template>
  167. <script setup>
  168. import { ref, computed, watch } from "vue";
  169. import { Search, ArrowLeftBold, ArrowRightBold } from "@element-plus/icons-vue";
  170. import moment from "moment";
  171. import byForm from "@/components/byForm/index";
  172. import useUserStore from "@/store/modules/user";
  173. import { ElMessage } from "element-plus";
  174. const { proxy } = getCurrentInstance();
  175. const sourceList = ref({
  176. data: [],
  177. pagination: {
  178. pageNum: 1,
  179. pageSize: 10,
  180. keyword: "",
  181. createUser: "",
  182. participantId: "",
  183. startDate: "",
  184. endDate: "",
  185. },
  186. });
  187. const menuDefault = ref(2);
  188. const day = ref(moment().format("yyyy年MM月DD日"));
  189. const month = ref(moment().format("yyyy年MM月"));
  190. const status = ref("0");
  191. const tableStatus = ref([
  192. {
  193. label: "月",
  194. value: "0",
  195. },
  196. {
  197. label: "周",
  198. value: "1",
  199. },
  200. ]);
  201. const date = ref(moment().format("yyyy-MM-DD"));
  202. const calendar = ref();
  203. watch(
  204. () => date.value,
  205. (newValue) => {
  206. if (month.value !== moment(newValue).format("yyyy年MM月")) {
  207. month.value = moment(newValue).format("yyyy年MM月");
  208. console.log("date-change");
  209. getList();
  210. }
  211. }
  212. );
  213. const selectDate = (val) => {
  214. calendar.value.selectDate(val);
  215. };
  216. const handleSelectMenu = (index) => {
  217. console.log("handleSelectMenu", index);
  218. if (index === 1) {
  219. sourceList.value.pagination.createUser = useUserStore().user.userId;
  220. sourceList.value.pagination.participantId = "";
  221. } else if (index === 2) {
  222. sourceList.value.pagination.createUser = useUserStore().user.userId;
  223. sourceList.value.pagination.participantId = useUserStore().user.userId;
  224. } else if (index === 3) {
  225. sourceList.value.pagination.createUser = "";
  226. sourceList.value.pagination.participantId = useUserStore().user.userId;
  227. }
  228. getList();
  229. };
  230. const getList = async () => {
  231. sourceList.value.pagination.startDate = moment(month.value, "yyyy年MM月").format("yyyy-MM-DD");
  232. sourceList.value.pagination.endDate = moment(moment(month.value, "yyyy年MM月").add(+1, "month").add(-1, "days").calendar()).format("yyyy-MM-DD");
  233. console.log("getList", sourceList.value.pagination);
  234. proxy.post("/scheduleInfo/page", sourceList.value.pagination).then((res) => {
  235. console.log(res);
  236. // sourceList.value.data = res.rows;
  237. });
  238. };
  239. const clickToday = () => {
  240. console.log("clickToday", sourceList.value.pagination);
  241. };
  242. const prevMonth = () => {
  243. month.value = moment(moment(month.value, "yyyy年MM月").add(-1, "month").calendar()).format("yyyy年MM月");
  244. console.log("prevMonth", month.value);
  245. selectDate("prev-month");
  246. getList();
  247. };
  248. const nextMonth = () => {
  249. month.value = moment(moment(month.value, "yyyy年MM月").add(+1, "month").calendar()).format("yyyy年MM月");
  250. console.log("nextMonth", month.value);
  251. selectDate("next-month");
  252. getList();
  253. };
  254. const userList = ref([]);
  255. const getDict = () => {
  256. proxy.get("/tenantUser/list", { pageNum: 1, pageSize: 10000, tenantId: useUserStore().user.tenantId }).then((res) => {
  257. if (res.rows && res.rows.length > 0) {
  258. userList.value = res.rows.map((item) => {
  259. return {
  260. label: item.userName,
  261. value: item.userId,
  262. };
  263. });
  264. }
  265. });
  266. };
  267. getDict();
  268. handleSelectMenu(2);
  269. const openSchedule = ref(false);
  270. const loadingDialog = ref(false);
  271. const schedule = ref(null);
  272. const formOption = reactive({
  273. inline: true,
  274. labelWidth: 100,
  275. itemWidth: 100,
  276. rules: [],
  277. });
  278. const formData = reactive({
  279. data: {
  280. isAllDay: 0,
  281. participantList: [],
  282. },
  283. });
  284. // const repeatType = ref([
  285. // {
  286. // label: "不重复",
  287. // value: 0,
  288. // },
  289. // {
  290. // label: "每天重复",
  291. // value: 1,
  292. // },
  293. // {
  294. // label: "每周重复",
  295. // value: 2,
  296. // },
  297. // {
  298. // label: "每月重复",
  299. // value: 3,
  300. // },
  301. // ]);
  302. const noticeType = ref([
  303. {
  304. label: "提前15分钟",
  305. value: 15,
  306. },
  307. {
  308. label: "提前30分钟",
  309. value: 30,
  310. },
  311. {
  312. label: "提前1小时",
  313. value: 60,
  314. },
  315. ]);
  316. // const taskPermissions = ref([
  317. // {
  318. // label: "仅自己可见",
  319. // value: 0,
  320. // },
  321. // {
  322. // label: "参与人可见",
  323. // value: 1,
  324. // },
  325. // {
  326. // label: "全员可见",
  327. // value: 2,
  328. // },
  329. // ]);
  330. const predefineColors = ref([
  331. "#ff4500",
  332. "#ff8c00",
  333. "#ffd700",
  334. "#90ee90",
  335. "#00ced1",
  336. "#1e90ff",
  337. "#c71585",
  338. "#ff4500ad",
  339. "#ff7800",
  340. "#fad400",
  341. "#90f09080",
  342. "#00babd",
  343. "#1f93ffba",
  344. "#c7158577",
  345. ]);
  346. const formConfig = computed(() => {
  347. return [
  348. {
  349. type: "input",
  350. prop: "title",
  351. label: "标题",
  352. itemType: "text",
  353. },
  354. {
  355. type: "slot",
  356. prop: "time",
  357. slotName: "time",
  358. label: "时间",
  359. },
  360. {
  361. type: "slot",
  362. prop: "color",
  363. slotName: "color",
  364. label: "颜色",
  365. },
  366. {
  367. type: "slot",
  368. prop: "participantList",
  369. slotName: "participantList",
  370. label: "参与人",
  371. },
  372. // {
  373. // type: "input",
  374. // prop: "place",
  375. // label: "地点",
  376. // itemType: "text",
  377. // },
  378. {
  379. type: "slot",
  380. prop: "noticeType",
  381. slotName: "noticeType",
  382. label: "通知",
  383. },
  384. // {
  385. // type: "slot",
  386. // prop: "taskPermissions",
  387. // slotName: "taskPermissions",
  388. // label: "任务权限",
  389. // },
  390. {
  391. type: "input",
  392. prop: "remark",
  393. label: "具体描述",
  394. itemType: "textarea",
  395. },
  396. ];
  397. });
  398. const rules = ref({
  399. title: [{ required: true, message: "请输入标题", trigger: "blur" }],
  400. startDate: [{ required: true, message: "请选择开始时间", trigger: "change" }],
  401. endDate: [{ required: true, message: "请选择结束时间", trigger: "change" }],
  402. // repeatType: [{ required: true, message: "请选择重复类型", trigger: "change" }],
  403. color: [{ required: true, message: "请选择颜色", trigger: "change" }],
  404. participantList: [{ required: true, message: "请选择参与人", trigger: "change" }],
  405. // place: [{ required: true, message: "请输入日程、事项、活动地址等", trigger: "blur" }],
  406. noticeType: [{ required: true, message: "请选择通知类型", trigger: "change" }],
  407. // taskPermissions: [{ required: true, message: "请选择任务权限", trigger: "change" }],
  408. });
  409. const newSchedule = () => {
  410. formData.data = {
  411. isAllDay: 0,
  412. participantList: [],
  413. };
  414. loadingDialog.value = false;
  415. openSchedule.value = true;
  416. };
  417. const clickSubmit = () => {
  418. schedule.value.handleSubmit(() => {
  419. loadingDialog.value = true;
  420. let data = JSON.parse(JSON.stringify(formData.data));
  421. if (data.participantList && data.participantList.length > 0) {
  422. data.participantList = data.participantList.map((item) => {
  423. return {
  424. participantId: item,
  425. };
  426. });
  427. }
  428. proxy.post("/scheduleInfo/add", data).then(
  429. () => {
  430. ElMessage({
  431. message: "新建成功",
  432. type: "success",
  433. });
  434. openSchedule.value = false;
  435. getList();
  436. },
  437. (err) => {
  438. console.log(err);
  439. loadingDialog.value = false;
  440. }
  441. );
  442. });
  443. };
  444. </script>
  445. <style lang="scss" scoped>
  446. .outer-layer {
  447. margin: 20px;
  448. display: flex;
  449. justify-content: space-between;
  450. .schedule-left {
  451. width: 360px;
  452. background: #fff;
  453. height: calc(100vh - 100px - 40px);
  454. padding: 20px;
  455. overflow-y: auto;
  456. }
  457. .schedule-right {
  458. width: calc(100% - 380px);
  459. .schedule-top {
  460. width: 100%;
  461. background: #fff;
  462. padding: 20px;
  463. }
  464. .schedule-bottom {
  465. width: 100%;
  466. background: #fff;
  467. height: calc(100vh - 100px - 40px - 92px);
  468. padding: 20px;
  469. margin-top: 20px;
  470. overflow-y: auto;
  471. &::-webkit-scrollbar {
  472. width: 0px;
  473. }
  474. }
  475. }
  476. }
  477. ::v-deep(.el-menu) {
  478. border-right: 0;
  479. }
  480. ::v-deep(.el-menu-item) {
  481. height: 40px;
  482. }
  483. ::v-deep(.el-calendar__header) {
  484. display: none;
  485. }
  486. ::v-deep(.el-calendar__body) {
  487. padding: 0;
  488. }
  489. ::v-deep(.el-calendar-table .el-calendar-day) {
  490. padding: 0;
  491. min-height: calc((100vh - 100px - 40px - 92px - 50px - 40px) / 6);
  492. }
  493. .is-selected {
  494. color: #1989fa;
  495. }
  496. .title {
  497. text-align: center;
  498. height: 30px;
  499. line-height: 22px;
  500. position: relative;
  501. padding: 4px;
  502. .select-title {
  503. border-radius: 50px;
  504. background-color: #1989fa;
  505. color: #eee;
  506. padding: 4px;
  507. }
  508. }
  509. ::v-deep(.radio-color .el-radio) {
  510. margin-right: 8px;
  511. }
  512. ::v-deep(.radio-color .el-radio__input) {
  513. display: none;
  514. }
  515. ::v-deep(.radio-color .el-radio__label) {
  516. div {
  517. width: 24px;
  518. height: 24px;
  519. border-radius: 50px;
  520. }
  521. }
  522. </style>