电商商城定制开发Fullcalendar日历使用,包括视图选择、事件插入、编辑事件、事件状态更改、事件添加和删除、事件拖动调整,自定义头部,加入el-popover显示图片、图片预览、添加附件链接等,支持手机显示。

Fullcalendar电商商城定制开发这个插件挺好,电商商城定制开发就是很多方法感觉官方电商商城定制开发文档也没怎么说,电商商城定制开发导致上手难度大,电商商城定制开发而且有些默认事件真的不太友好...电商商城定制开发废话不多说,电商商城定制开发先上效果图!

1、效果GIF 

1.1 电商商城定制开发基本按钮功能

1.2  事件hover显示

 

1.3 事件添加、编辑、状态修改 

 

1.4 电商商城定制开发日历事件搜索 

 

2、 代码实现

 2.1 Fullcalendar日历、el-popover弹窗

        Fullcalendar@5.11.3引入后,电商商城定制开发要设置一大堆参数calendarOptions,电商商城定制开发包括显示时间区域、默认视图、电商商城定制开发是否显示全天类型、中文界面、电商商城定制开发事件的操作函数等,电商商城定制开发具体的一些设置内容,电商商城定制开发见下面代码的注释。

  1. <template>
  2. <FullCalendar
  3. class="calendar"
  4. ref="fullCalendar"
  5. :options="calendarOptions"
  6. ><template v-slot:eventContent="arg">
  7. <el-popover
  8. :append-to-body="true"
  9. ref="popover1"
  10. placement="top-start"
  11. width="220"
  12. :visible-arrow="true"
  13. trigger="hover"
  14. :teleported="false"
  15. popper-class="popover"
  16. :open-delay="100"
  17. @show="showPic(arg)"
  18. @hide="popoverPicReset(arg)"
  19. >
  20. <el-row class="popover_title">
  21. <el-col
  22. :span="12"
  23. :style="{
  24. color:
  25. arg.event.extendedProps.isDone == false
  26. ? 'red'
  27. : 'green',
  28. }"
  29. >
  30. <span
  31. style="padding-right: 2px"
  32. :style="{
  33. 'border-left':
  34. arg.event.extendedProps.isDone == false
  35. ? '5px solid red'
  36. : '5px solid green',
  37. }"
  38. ></span
  39. >{{
  40. arg.event.extendedProps.isDone == false
  41. ? "未开始"
  42. : "已完成"
  43. }}</el-col
  44. >
  45. <el-col
  46. :span="12"
  47. style="
  48. display: flex;
  49. flex-direction: row-reverse;
  50. font-size: 14;
  51. color: #000;
  52. "
  53. >{{
  54. arg.event.allDay == true
  55. ? "全天"
  56. : formatTimer(arg.event.start)
  57. }}</el-col
  58. >
  59. </el-row>
  60. <el-row>
  61. <el-col :span="24" style="text-align: center">
  62. <el-image
  63. v-if="popoverimg.length != 0"
  64. :src="popoverimg[0]"
  65. @click="PreviewPic(popoverimg)"
  66. fit="fill"
  67. class="popoverShowImg"
  68. ><div slot="placeholder" class="image-slot">
  69. 加载中<span class="dot">...</span>
  70. </div></el-image
  71. >
  72. <div class="block"></div>
  73. </el-col>
  74. </el-row>
  75. <el-row class="popover_content">
  76. <el-col :span="24" style="max-height: 150px; overflow: auto">
  77. <span class="click">{{ arg.event.title }}</span>
  78. </el-col>
  79. <el-col :span="24">
  80. <el-link
  81. v-if="
  82. arg.event.extendedProps.address != null &&
  83. arg.event.extendedProps.address != ''
  84. "
  85. :href="undefined"
  86. :underline="false"
  87. @click="fileDownload(arg.event.extendedProps.address)"
  88. class="link"
  89. >{{
  90. arg.event.extendedProps.address == null
  91. ? ""
  92. : arg.event.extendedProps.address.replace(
  93. "D:\\flask\\upload\\",
  94. ""
  95. )
  96. }}</el-link
  97. ></el-col
  98. >
  99. </el-row>
  100. <el-row style="margin-top: 5px"
  101. ><el-col style="width: 15%"
  102. ><div>
  103. <el-button
  104. class="hvr-icon-pulse-grow"
  105. :popperAppendToBody="false"
  106. size="mini"
  107. icon="el-icon-edit hvr-icon"
  108. type="primary"
  109. circle
  110. @click="handleEventClick(arg)"
  111. >
  112. </el-button>
  113. </div>
  114. </el-col>
  115. <el-col style="width: 15%"
  116. ><el-button
  117. class="hvr-icon-bounce"
  118. size="mini"
  119. type="success"
  120. icon="el-icon-document-checked hvr-icon"
  121. circle
  122. @click="onCheckBtnClicked(arg)"
  123. >
  124. </el-button>
  125. </el-col>
  126. <el-col style="width: 15%"
  127. ><el-popconfirm
  128. confirm-button-text="好"
  129. cancel-button-text="否"
  130. icon="el-icon-info"
  131. icon-color="red"
  132. title="电商商城定制开发确定删除这个事项吗?"
  133. @confirm="onRemoveBtnClicked(arg)"
  134. ><el-button
  135. class="hvr-icon-buzz-out"
  136. slot="reference"
  137. size="mini"
  138. type="danger"
  139. icon="el-icon-delete hvr-icon"
  140. circle
  141. >
  142. </el-button
  143. ></el-popconfirm> </el-col
  144. ></el-row>
  145. <div slot="reference">
  146. <span class="tree_span_text">{{ arg.timeText }}</span>
  147. <span>{{ arg.event.title }}</span>
  148. </div>
  149. </el-popover>
  150. </template>
  151. </FullCalendar>
  152. </template>
  153. <script>
  154. import FullCalendar from "@fullcalendar/vue";
  155. import dayGridPlugin from "@fullcalendar/daygrid";
  156. import timeGridPlugin from "@fullcalendar/timegrid";
  157. import interactionPlugin from "@fullcalendar/interaction";
  158. import listPlugin from "@fullcalendar/list";
  159. export default {
  160. // 电商商城定制开发注册局部组件
  161. components: {
  162. FullCalendar,
  163. Treeselect,
  164. "el-image-viewer": () =>
  165. import("element-ui/packages/image/src/image-viewer"),
  166. },
  167. data() {
  168. return {
  169. // Fullcalendar版本@5.11.3电商商城定制开发日历控件设置项,电商商城定制开发官网文档地址:https://fullcalendar.io/
  170. calendarOptions: {
  171. visibleRange: { start: "2000-01-01", end: "2100-12-31" }, // 电商商城定制开发可视化区间,必须设置,电商商城定制开发否则查询列表不会显示事件
  172. // validRange: { start: "2021-09-01", end: "2021-09-01" }, // 电商商城定制开发可展示区间
  173. // 电商商城定制开发引入的插件,比如fullcalendar/daygrid,fullcalendar/timegrid电商商城定制开发引入后才可显示月,周,日
  174. plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin],
  175. initialView: "dayGridMonth", // 默认为那个视图(月:dayGridMonth,周:timeGridWeek,日:timeGridDay)
  176. firstDay: 1, // 设置一周中显示的第一天是哪天,周日是0,周一是1,类推
  177. locale: "zh-cn", // 切换语言,当前为中文
  178. allDaySlot: true, // 不显示all-day
  179. businessHours: true, //
  180. handleWindowResize: true, // 是否随浏览器窗口大小变化而自动变化。
  181. allDayText: "全天", // 设置all-Day显示的文字,不设置的话默认显示"all-Day"
  182. themeSystem: "bootstrap", // 主题色(本地测试未能生效)
  183. // loading: this.loadingEvent, // 视图数据加载中、加载完成触发(用于配合显示/隐藏加载指示器。)
  184. // selectAllow: this.selectAllow, //编程控制用户可以选择的地方,返回true则表示可选择,false表示不可选择
  185. // eventMouseEnter: this.eventMouseEnter, // 鼠标滑过
  186. allowContextMenu: false,
  187. editable: true, // 是否可以进行(拖动、缩放)修改
  188. eventStartEditable: true, // Event日程开始时间可以改变,默认true,如果是false其实就是指日程块不能随意拖动,只能上下拉伸改变他的endTime
  189. eventDurationEditable: true, // Event日程的开始结束时间距离是否可以改变,默认true,如果是false则表示开始结束时间范围不能拉伸,只能拖拽
  190. selectable: true, // 是否可以选中日历格
  191. selectMirror: true,
  192. selectMinDistance: 0, // 选中日历格的最小距离
  193. // eventLimit: true, //数据条数太多时,限制各自里显示的数据条数(多余的以“+2more”格式显示),默认false不限制,支持输入数字设定固定的显示条数
  194. moreLinkContent: "+ 更多", //当一块区域内容太多以"+2 more"格式显示时,这个more的名称自定义
  195. // dayPopoverFormat: "YYYY-M-d",
  196. dayMaxEventRows: true, // 日历显示事件最大条数,for all non-TimeGrid views
  197. weekends: true, //
  198. navLinks: true, // 天链接
  199. selectHelper: false,
  200. slotEventOverlap: false, // 相同时间段的多个日程视觉上是否允许重叠,默认true允许
  201. aspectRatio: 1.35, //设置日历单元格宽度与高度的比例。
  202. expandRows: true,
  203. height: auto,
  204. contentHeight: 100,
  205. nowIndicator: true, //周/日视图中显示今天当前时间点(以红线标记),默认false不显示
  206. weekMode: "fixed", //在月视图里显示周的模式,因为每月周数可能不同,所以月视图高度不一定。fixed:固定显示6周高,日历高度保持不变liquid:不固定周数,高度随周数变化variable:不固定周数,但高度固定
  207. weekNumbers: true, //是否在日历中显示周次(一年中的第几周),如果设置为true,则会在月视图的左侧、周视图和日视图的左上角显示周数。
  208. weekText: "周",
  209. customButtons: {
  210. //自定义按钮
  211. getToday: {
  212. text: "今天",
  213. click: this.getToday,
  214. },
  215. getNext: {
  216. text: ">",
  217. click: this.getNext,
  218. },
  219. getPrev: {
  220. text: "<",
  221. click: this.getPrev,
  222. },
  223. getPrevYear: {
  224. text: "<<",
  225. click: this.getPrevYear,
  226. },
  227. getNextYear: {
  228. text: ">>",
  229. click: this.getNextYear,
  230. },
  231. customButton: {
  232. text: "今日标记全部已完成",
  233. click: this.customButton,
  234. },
  235. customButton1: {
  236. text: "显示未完成",
  237. click: this.customButton,
  238. },
  239. },
  240. // 日历头部按钮,即Fullcalendar表头显示区域
  241. // headerToolbar: {
  242. // left: "getPrevYear,getPrev,getToday,getNext,getNextYear", //"getPrevYear,getPrev,getToday,getNext,getNextYear customButton,customButton1",
  243. // center: "title",
  244. // right:
  245. // "customButton customButton1 dayGridMonth,timeGridWeek,timeGridDay,listMonth", //dayGridWeek,listMonth
  246. // },
  247. headerToolbar: false, // Fullcalendar表头显示区域不显示,显示自己自定义的html头部
  248. // 使用内置按钮的显示文本
  249. buttonText: {
  250. today: "今天",
  251. month: "月",
  252. week: "周",
  253. day: "日",
  254. list: "日程",
  255. },
  256. // 设置日历显示事件时间头
  257. slotLabelFormat: {
  258. hour: "2-digit",
  259. minute: "2-digit",
  260. meridiem: false,
  261. hour12: false, // 设置时间为24小时
  262. },
  263. // 视图的一些基本设置
  264. views: {
  265. // 月视图阳历转农历
  266. dayGridMonth: {
  267. height: 500,
  268. displayEventTime: true, //是否显示时间
  269. dayMaxEventRows: 4, // adjust to 6 only for timeGridWeek/timeGridDay
  270. // titleFormat: { year: "numeric", month: "2-digit", day: "2-digit" }, //控制日历显示的标题
  271. // moreLinkContent: "+ 更多", //可放在这里单独对每个视图控制显示更多的文字
  272. moreLinkClick: "popover",
  273. eventTimeFormat: {
  274. hour: "numeric",
  275. minute: "2-digit",
  276. meridiem: false,
  277. },
  278. dayPopoverFormat: {
  279. month: "long",
  280. day: "numeric",
  281. year: "numeric",
  282. },
  283. // 显示农历
  284. // dayCellContent(item) {
  285. // let _date = new Date(item.date).toLocaleDateString().split("/");
  286. // let _dateF = calendar.solarToLunar(_date[0], _date[1], _date[2]);
  287. // // 以二十四节气覆盖农历日期
  288. // if (calendar.getLunar24Days(_date[0], _date[1], _date[2])) {
  289. // _dateF.dayStr = calendar.getLunar24Days(
  290. // _date[0],
  291. // _date[1],
  292. // _date[2]
  293. // );
  294. // }
  295. // return { html: `<p>${item.dayNumberText}(${_dateF.dayStr})</p>` };
  296. // },
  297. },
  298. timeGridWeek: {},
  299. timeGridDay: {},
  300. listMonth: {},
  301. },
  302. // 设置过往时间无法点击
  303. // selectAllow: function (clickInfo) {
  304. // if (clickInfo.end < new Date()) {
  305. // return false;
  306. // }
  307. // return true;
  308. // },
  309. weekends: true, //是否显示周末,设为false则不显示周六和周日
  310. selectable: true, //是否可以选中日历格
  311. editable: false, //是否可以进行(拖动、缩放)修改
  312. navLinks: true, //天链接
  313. select: this.selectDate, //选中日历格事件
  314. eventClick: this.handleEventClick, //选中备忘录事件
  315. eventsSet: this.handleEvents,
  316. events: this.getCalendarList, //获取数据源
  317. eventMouseEnter: this.eventMouseEnter, //鼠标悬浮事件
  318. slotEventOverlap: true, //相同时间段的多个日程视觉上是否允许重叠,默认true允许
  319. eventResize: this.onEventResize, // 事件时间区间调整
  320. eventDrop: this.onEventResize, // 事件Drag-Drop事件
  321. eventMouseLeave: this.eventMouseLeave, // 鼠标移出事件发生的事件
  322. },
  323. };
  324. },
  325. }
  326. </script>

         在这里,鼠标在事件上面经过时,会显示一个弹出窗,如下图。可见,弹出框有:是否已完成,开始时间,图列说明(可以是图片、GIF等),文字说明、链接或是附件。以上的这些都是用el-popover实现,用了v-slot:eventContent="arg",将日历的数据进行处理。图片的显示需要修改源码才能显示,不然有bug显示不出来,修改的源码见此文章第3节内容

 2.2 Fullcalendar日历自定义头部

        在calendarOptions设置里,修改headerToolbar,设置为false。

         然后写好自己的html代码,并调整好css样式。

         绑定自定义按钮的函数功能,主要是利用了calendarApi自带的函数功能,包括视图切换、月日视图切换、往前和往后功能等,当然搜索功能是自己定义的。

  2.3 搜索功能

        这里是onSearch函数功能,主要是在前端对events的过滤,然后再设置视图为list视图,注意这个视图在日历头部的功能区是没有的,但是是Fullcalendar内置的。当搜索框为空或者清空搜索字符后,需要重新请求后端数据。 

3、Fullcalendar源码修改

3.1 修改源码main.js的地址:

 3.2 添加的show_pic函数/方法:

  1. CalendarApi.prototype.show_pic = function (arg) {
  2. var state = this.getCurrentData();
  3. this.unselect();
  4. // 出现图片的关键
  5. this.dispatch({
  6. type: 'CHANGE_DATE',
  7. dateMarker: state.dateEnv.createMarker(arg.view.currentStart),
  8. });
  9. };

4、Vue源码

  1. <template>
  2. <!-- el-mian是个人右侧容器的设置组件 -->
  3. <el-main>
  4. <div>
  5. <!-- 日历头部div -->
  6. <div class="fc-toolbar" style="display: flex; margin-bottom: 2px">
  7. <!-- 日历头部左侧显示区域 -->
  8. <div class="fc-left" style="flex: 1; justify-content: flex-start">
  9. <div style="vertical-align: middle">
  10. <el-input
  11. placeholder="请输入查询内容"
  12. v-model="search_input"
  13. clearable
  14. class="input"
  15. size="medium"
  16. @keyup.enter.native="onSearch"
  17. @clear="getToday()"
  18. >
  19. <i slot="suffix" class="el-icon-search" @click="onSearch"></i>
  20. </el-input>
  21. </div>
  22. </div>
  23. <!-- 日历头部中间显示区域 -->
  24. <div
  25. class="fc-center"
  26. style="display: flex; flex: 3; justify-content: center"
  27. >
  28. <el-button-group>
  29. <el-button
  30. icon="el-icon-d-arrow-left"
  31. @click="getPrevYear"
  32. class="fc_btns"
  33. ></el-button>
  34. <el-button
  35. icon="el-icon-arrow-left"
  36. @click="getPrev"
  37. class="fc_btns"
  38. ></el-button>
  39. </el-button-group>
  40. <h2 class="title">
  41. {{ title }}
  42. </h2>
  43. <el-button-group>
  44. <el-button
  45. icon="el-icon-arrow-right"
  46. @click="getNext"
  47. class="fc_btns"
  48. ></el-button>
  49. <el-button
  50. icon="el-icon-d-arrow-right"
  51. @click="getNextYear"
  52. class="fc_btns"
  53. ></el-button>
  54. </el-button-group>
  55. </div>
  56. <!-- 显示图标注释栏 -->
  57. <!-- <div class="tips" style="display: flex">
  58. <div
  59. style="
  60. height: 14px;
  61. width: 14px;
  62. background: green;
  63. text-align: center;
  64. position: relative;
  65. top: 27%;
  66. "
  67. ></div>
  68. <span class="tip-content">已完成</span>
  69. <div
  70. style="
  71. height: 14px;
  72. width: 14px;
  73. background: #fe9b02;
  74. text-align: center;
  75. position: relative;
  76. top: 27%;
  77. "
  78. ></div>
  79. <span class="tip-content">未开始</span>
  80. </div> -->
  81. <!-- 日历头部右侧显示区域 -->
  82. <div class="fc-right">
  83. <el-button-group>
  84. <el-button
  85. @click="today"
  86. type="success"
  87. plain
  88. size="medium"
  89. class="fc_btns"
  90. >今天</el-button
  91. >
  92. <el-button
  93. @click="month"
  94. type="primary"
  95. plain
  96. size="medium"
  97. class="fc_btns"
  98. >月</el-button
  99. >
  100. <el-button
  101. @click="week"
  102. type="primary"
  103. plain
  104. size="medium"
  105. class="fc_btns"
  106. >周</el-button
  107. >
  108. <el-button
  109. @click="day"
  110. type="primary"
  111. plain
  112. size="medium"
  113. class="fc_btns"
  114. >日</el-button
  115. >
  116. <el-button
  117. @click="list"
  118. type="primary"
  119. plain
  120. size="medium"
  121. class="fc_btns"
  122. >列表</el-button
  123. >
  124. </el-button-group>
  125. </div>
  126. </div>
  127. </div>
  128. <!-- 日历本体 -->
  129. <el-row>
  130. <el-col :md="24" :xs="24">
  131. <div style="margin-top: 0px">
  132. <FullCalendar
  133. class="calendar"
  134. ref="fullCalendar"
  135. :options="calendarOptions"
  136. ><template v-slot:eventContent="arg">
  137. <el-popover
  138. :append-to-body="true"
  139. ref="popover1"
  140. placement="top-start"
  141. width="220"
  142. :visible-arrow="true"
  143. trigger="hover"
  144. :teleported="false"
  145. popper-class="popover"
  146. :open-delay="100"
  147. @show="showPic(arg)"
  148. @hide="popoverPicReset(arg)"
  149. >
  150. <el-row class="popover_title">
  151. <el-col
  152. :span="12"
  153. :style="{
  154. color:
  155. arg.event.extendedProps.isDone == false
  156. ? 'red'
  157. : 'green',
  158. }"
  159. >
  160. <span
  161. style="padding-right: 2px"
  162. :style="{
  163. 'border-left':
  164. arg.event.extendedProps.isDone == false
  165. ? '5px solid red'
  166. : '5px solid green',
  167. }"
  168. ></span
  169. >{{
  170. arg.event.extendedProps.isDone == false
  171. ? "未开始"
  172. : "已完成"
  173. }}</el-col
  174. >
  175. <el-col
  176. :span="12"
  177. style="
  178. display: flex;
  179. flex-direction: row-reverse;
  180. font-size: 14;
  181. color: #000;
  182. "
  183. >{{
  184. arg.event.allDay == true
  185. ? "全天"
  186. : formatTimer(arg.event.start)
  187. }}</el-col
  188. >
  189. </el-row>
  190. <el-row>
  191. <el-col :span="24" style="text-align: center">
  192. <el-image
  193. v-if="popoverimg.length != 0"
  194. :src="popoverimg[0]"
  195. @click="PreviewPic(popoverimg)"
  196. fit="fill"
  197. class="popoverShowImg"
  198. ><div slot="placeholder" class="image-slot">
  199. 加载中<span class="dot">...</span>
  200. </div></el-image
  201. >
  202. <div class="block"></div>
  203. </el-col>
  204. </el-row>
  205. <el-row class="popover_content">
  206. <el-col :span="24" style="max-height: 150px; overflow: auto">
  207. <span class="click">{{ arg.event.title }}</span>
  208. </el-col>
  209. <el-col :span="24">
  210. <el-link
  211. v-if="
  212. arg.event.extendedProps.address != null &&
  213. arg.event.extendedProps.address != ''
  214. "
  215. :href="undefined"
  216. :underline="false"
  217. @click="fileDownload(arg.event.extendedProps.address)"
  218. class="link"
  219. >{{
  220. arg.event.extendedProps.address == null
  221. ? ""
  222. : arg.event.extendedProps.address.replace(
  223. "D:\\flask\\upload\\",
  224. ""
  225. )
  226. }}</el-link
  227. ></el-col
  228. >
  229. </el-row>
  230. <el-row style="margin-top: 5px"
  231. ><el-col style="width: 15%"
  232. ><div>
  233. <el-button
  234. class="hvr-icon-pulse-grow"
  235. :popperAppendToBody="false"
  236. size="mini"
  237. icon="el-icon-edit hvr-icon"
  238. type="primary"
  239. circle
  240. @click="handleEventClick(arg)"
  241. >
  242. </el-button>
  243. </div>
  244. </el-col>
  245. <el-col style="width: 15%"
  246. ><el-button
  247. class="hvr-icon-bounce"
  248. size="mini"
  249. type="success"
  250. icon="el-icon-document-checked hvr-icon"
  251. circle
  252. @click="onCheckBtnClicked(arg)"
  253. >
  254. </el-button>
  255. </el-col>
  256. <el-col style="width: 15%"
  257. ><el-popconfirm
  258. confirm-button-text="好"
  259. cancel-button-text="否"
  260. icon="el-icon-info"
  261. icon-color="red"
  262. title="确定删除这个事项吗?"
  263. @confirm="onRemoveBtnClicked(arg)"
  264. ><el-button
  265. class="hvr-icon-buzz-out"
  266. slot="reference"
  267. size="mini"
  268. type="danger"
  269. icon="el-icon-delete hvr-icon"
  270. circle
  271. >
  272. </el-button
  273. ></el-popconfirm> </el-col
  274. ></el-row>
  275. <div slot="reference">
  276. <span class="tree_span_text">{{ arg.timeText }}</span>
  277. <span>{{ arg.event.title }}</span>
  278. </div>
  279. </el-popover>
  280. </template>
  281. </FullCalendar>
  282. </div>
  283. <!-- 事件添加或修改对话框 -->
  284. <el-dialog
  285. :visible.sync="dialogVisible"
  286. :popperAppendToBody="false"
  287. @close="cancel"
  288. v-dialogDrag
  289. :close-on-click-modal="false"
  290. class="calendar_matters"
  291. >
  292. <div slot="title" class="header-title" :style="{ color: 'black' }">
  293. <i class="el-icon-edit"></i><span> &nbsp;事件</span>
  294. </div>
  295. <el-form ref="form" :model="form" label-width="80px">
  296. <el-row>
  297. <el-col :span="12" :xs="24">
  298. <el-form-item label="事件时间">
  299. <div class="dateRange">
  300. <el-date-picker
  301. v-model="dateRange"
  302. type="datetimerange"
  303. range-separator="至"
  304. start-placeholder="开始日期"
  305. end-placeholder="结束日期"
  306. >
  307. </el-date-picker>
  308. </div>
  309. </el-form-item>
  310. </el-col>
  311. <el-col :span="12"> </el-col>
  312. </el-row>
  313. <el-row>
  314. <el-col :span="24"
  315. ><el-form-item label="具体事项">
  316. <el-input
  317. v-model="form.remark"
  318. type="textarea"
  319. class="calendar_details"
  320. ></el-input> </el-form-item
  321. ></el-col>
  322. </el-row>
  323. <el-row>
  324. <el-col :span="12" :xs="24"
  325. ><el-form-item label="提醒类别" prop="deptId">
  326. <treeselect
  327. v-model="form.category"
  328. :options="Options"
  329. :props="defaultProps"
  330. :show-count="true"
  331. placeholder="请选择类型"
  332. @select="categorySelected"
  333. /> </el-form-item
  334. ></el-col>
  335. <el-col :span="12" :xs="24"
  336. ><el-form-item
  337. v-if="form.userId == undefined"
  338. label="记录人"
  339. prop="userName"
  340. >
  341. <el-input
  342. v-model="form.userName"
  343. maxlength="30"
  344. disabled
  345. class="userName"
  346. /> </el-form-item
  347. ></el-col>
  348. </el-row>
  349. <el-row>
  350. <el-col :span="12"> </el-col>
  351. <el-col :span="12" :xs="24">
  352. <el-form-item label="状态">
  353. <el-radio-group v-model="form.isDone">
  354. <el-radio label="0">已完成</el-radio>
  355. <el-radio label="1">未确认</el-radio>
  356. </el-radio-group>
  357. </el-form-item>
  358. </el-col>
  359. </el-row>
  360. <el-row>
  361. <el-col :span="18" :xs="24">
  362. <el-form-item label="附件" class="attachment" prop="address">
  363. <el-upload
  364. action="#"
  365. :show-file-list="false"
  366. :auto-upload="false"
  367. :on-change="address_beforeupload"
  368. >
  369. <div>
  370. <el-button
  371. type="primary"
  372. icon="el-icon-folder-opened"
  373. ></el-button>
  374. </div>
  375. </el-upload>
  376. <el-input
  377. v-model="form.address"
  378. clearable
  379. ></el-input></el-form-item
  380. ></el-col>
  381. </el-row>
  382. <el-row>
  383. <el-col :span="24" :xs="24">
  384. <el-form-item label="相关图片" prop="address">
  385. <el-upload
  386. ref="uploadFile"
  387. class="upload-demo"
  388. action="#"
  389. :auto-upload="false"
  390. :show-file-list="true"
  391. :on-change="beforeupload"
  392. list-type="picture-card"
  393. :file-list="filelist"
  394. multiple
  395. >
  396. <i slot="default" class="el-icon-plus"></i>
  397. <div slot="file" slot-scope="{ file }">
  398. <img
  399. class="el-upload-list__item-thumbnail"
  400. :src="file.url"
  401. alt=""
  402. />
  403. <span class="el-upload-list__item-actions">
  404. <span
  405. class="el-upload-list__item-preview"
  406. @click="handlePictureCardPreview(file)"
  407. >
  408. <i class="el-icon-zoom-in"></i>
  409. </span>
  410. <span
  411. v-if="!disabled"
  412. class="el-upload-list__item-delete"
  413. @click="handleDownload(file)"
  414. >
  415. <i class="el-icon-download"></i>
  416. </span>
  417. <span
  418. v-if="!disabled"
  419. class="el-upload-list__item-delete"
  420. @click="handleRemove(file)"
  421. >
  422. <i class="el-icon-delete"></i>
  423. </span>
  424. </span>
  425. </div>
  426. </el-upload>
  427. </el-form-item>
  428. </el-col>
  429. </el-row>
  430. </el-form>
  431. <div slot="footer" class="dialog-footer">
  432. <el-button type="primary" @click="submitForm">确 定</el-button>
  433. <el-button @click="cancel">取 消</el-button>
  434. </div>
  435. </el-dialog>
  436. <!-- 图片预览对话框 -->
  437. <el-image-viewer
  438. v-if="img_dialogVisible"
  439. :initial-index="0"
  440. :on-close="onClose"
  441. :url-list="dialogImageUrl"
  442. style="z-index: 3000"
  443. ></el-image-viewer>
  444. </el-col>
  445. </el-row>
  446. </el-main>
  447. </template>
  448. <script>
  449. // import { getCalendarList } from "@/api/calendar.js";
  450. import FullCalendar from "@fullcalendar/vue";
  451. import dayGridPlugin from "@fullcalendar/daygrid";
  452. import timeGridPlugin from "@fullcalendar/timegrid";
  453. import interactionPlugin from "@fullcalendar/interaction";
  454. import listPlugin from "@fullcalendar/list";
  455. // import tippy from "tippy.js";
  456. // import "../../assets/tippy.css";
  457. // import calendar from "../../utils/calendar.js";
  458. // import { INITIAL_EVENTS, createEventId } from "./event-utils";
  459. import { auto } from "@popperjs/core";
  460. import "../../directives.js"; // v-dialogDrag: 弹窗可拖拽属性
  461. import Treeselect from "@riophae/vue-treeselect"; // Treeselect插件
  462. import "@riophae/vue-treeselect/dist/vue-treeselect.css"; // 若依css设置
  463. export default {
  464. // 注册局部组件
  465. components: {
  466. FullCalendar,
  467. Treeselect,
  468. "el-image-viewer": () =>
  469. import("element-ui/packages/image/src/image-viewer"),
  470. },
  471. data() {
  472. return {
  473. // 搜索框输入的文本
  474. search_input: "",
  475. // treeselect插件默认配置
  476. defaultProps: {
  477. children: "children",
  478. label: "label",
  479. },
  480. // 提醒类别设置
  481. Options: [
  482. {
  483. id: "工作类别",
  484. pid: 0,
  485. label: "工作类别",
  486. children: [],
  487. },
  488. {
  489. id: "生活类别",
  490. pid: 0,
  491. label: "生活类别",
  492. children: [],
  493. },
  494. {
  495. id: "其他类别",
  496. pid: 0,
  497. label: "其他类别",
  498. children: [],
  499. },
  500. {
  501. id: "",
  502. pid: 0,
  503. label: "无",
  504. children: [],
  505. },
  506. ],
  507. // 表单是否显示
  508. dialogVisible: false,
  509. // 表单标题栏
  510. title: "事件",
  511. // 表单当前编辑模式设置,add或amend
  512. form_edited_state: "",
  513. // 表单内容设置项
  514. form: {
  515. remark: undefined,
  516. isDone: undefined,
  517. img: "",
  518. address: "",
  519. },
  520. // 表单日期设置
  521. dateRange: [],
  522. // 图片预览的操作按钮是否展示
  523. disabled: false,
  524. // 图片是否显示
  525. img_dialogVisible: false,
  526. // 预览图片地址
  527. dialogImageUrl: "",
  528. // el-popover弹出框标题内容
  529. popover_title: "事项",
  530. // el-popover图片地址存放
  531. popoverimg: [],
  532. // 附件地址存放
  533. filelist: [],
  534. // ------------------
  535. // Fullcalendar版本@5.11.3日历控件设置项,官网文档地址:https://fullcalendar.io/
  536. calendarOptions: {
  537. // visibleRange: { start: "2021-09-01", end: "2022-10-01" }, // 可视化区间
  538. // validRange: { start: "2021-09-01", end: "2021-09-01" }, // 可展示区间
  539. // 引入的插件,比如fullcalendar/daygrid,fullcalendar/timegrid引入后才可显示月,周,日
  540. plugins: [dayGridPlugin, interactionPlugin, timeGridPlugin, listPlugin],
  541. initialView: "dayGridMonth", // 默认为那个视图(月:dayGridMonth,周:timeGridWeek,日:timeGridDay)
  542. firstDay: 1, // 设置一周中显示的第一天是哪天,周日是0,周一是1,类推
  543. locale: "zh-cn", // 切换语言,当前为中文
  544. allDaySlot: true, // 不显示all-day
  545. businessHours: true, //
  546. handleWindowResize: true, // 是否随浏览器窗口大小变化而自动变化。
  547. allDayText: "全天", // 设置all-Day显示的文字,不设置的话默认显示"all-Day"
  548. themeSystem: "bootstrap", // 主题色(本地测试未能生效)
  549. // loading: this.loadingEvent, // 视图数据加载中、加载完成触发(用于配合显示/隐藏加载指示器。)
  550. // selectAllow: this.selectAllow, //编程控制用户可以选择的地方,返回true则表示可选择,false表示不可选择
  551. // eventMouseEnter: this.eventMouseEnter, // 鼠标滑过
  552. allowContextMenu: false,
  553. editable: true, // 是否可以进行(拖动、缩放)修改
  554. eventStartEditable: true, // Event日程开始时间可以改变,默认true,如果是false其实就是指日程块不能随意拖动,只能上下拉伸改变他的endTime
  555. eventDurationEditable: true, // Event日程的开始结束时间距离是否可以改变,默认true,如果是false则表示开始结束时间范围不能拉伸,只能拖拽
  556. selectable: true, // 是否可以选中日历格
  557. selectMirror: true,
  558. selectMinDistance: 0, // 选中日历格的最小距离
  559. // eventLimit: true, //数据条数太多时,限制各自里显示的数据条数(多余的以“+2more”格式显示),默认false不限制,支持输入数字设定固定的显示条数
  560. moreLinkContent: "+ 更多", //当一块区域内容太多以"+2 more"格式显示时,这个more的名称自定义
  561. // dayPopoverFormat: "YYYY-M-d",
  562. dayMaxEventRows: true, // 日历显示事件最大条数,for all non-TimeGrid views
  563. weekends: true, //
  564. navLinks: true, // 天链接
  565. selectHelper: false,
  566. slotEventOverlap: false, // 相同时间段的多个日程视觉上是否允许重叠,默认true允许
  567. aspectRatio: 1.35, //设置日历单元格宽度与高度的比例。
  568. expandRows: true,
  569. height: auto,
  570. contentHeight: 100,
  571. nowIndicator: true, //周/日视图中显示今天当前时间点(以红线标记),默认false不显示
  572. weekMode: "fixed", //在月视图里显示周的模式,因为每月周数可能不同,所以月视图高度不一定。fixed:固定显示6周高,日历高度保持不变liquid:不固定周数,高度随周数变化variable:不固定周数,但高度固定
  573. weekNumbers: true, //是否在日历中显示周次(一年中的第几周),如果设置为true,则会在月视图的左侧、周视图和日视图的左上角显示周数。
  574. weekText: "周",
  575. customButtons: {
  576. //自定义按钮
  577. getToday: {
  578. text: "今天",
  579. click: this.getToday,
  580. },
  581. getNext: {
  582. text: ">",
  583. click: this.getNext,
  584. },
  585. getPrev: {
  586. text: "<",
  587. click: this.getPrev,
  588. },
  589. getPrevYear: {
  590. text: "<<",
  591. click: this.getPrevYear,
  592. },
  593. getNextYear: {
  594. text: ">>",
  595. click: this.getNextYear,
  596. },
  597. customButton: {
  598. text: "今日标记全部已完成",
  599. click: this.customButton,
  600. },
  601. customButton1: {
  602. text: "显示未完成",
  603. click: this.customButton,
  604. },
  605. },
  606. // 日历头部按钮,即Fullcalendar表头显示区域
  607. // headerToolbar: {
  608. // left: "getPrevYear,getPrev,getToday,getNext,getNextYear", //"getPrevYear,getPrev,getToday,getNext,getNextYear customButton,customButton1",
  609. // center: "title",
  610. // right:
  611. // "customButton customButton1 dayGridMonth,timeGridWeek,timeGridDay,listMonth", //dayGridWeek,listMonth
  612. // },
  613. headerToolbar: false, // Fullcalendar表头显示区域不显示,显示自己自定义的html头部
  614. // 使用内置按钮的显示文本
  615. buttonText: {
  616. today: "今天",
  617. month: "月",
  618. week: "周",
  619. day: "日",
  620. list: "日程",
  621. },
  622. // 设置日历显示事件时间头
  623. slotLabelFormat: {
  624. hour: "2-digit",
  625. minute: "2-digit",
  626. meridiem: false,
  627. hour12: false, // 设置时间为24小时
  628. },
  629. // 视图的一些基本设置
  630. views: {
  631. // 月视图阳历转农历
  632. dayGridMonth: {
  633. height: 500,
  634. displayEventTime: true, //是否显示时间
  635. dayMaxEventRows: 4, // adjust to 6 only for timeGridWeek/timeGridDay
  636. // titleFormat: { year: "numeric", month: "2-digit", day: "2-digit" }, //控制日历显示的标题
  637. // moreLinkContent: "+ 更多", //可放在这里单独对每个视图控制显示更多的文字
  638. moreLinkClick: "popover",
  639. eventTimeFormat: {
  640. hour: "numeric",
  641. minute: "2-digit",
  642. meridiem: false,
  643. },
  644. dayPopoverFormat: {
  645. month: "long",
  646. day: "numeric",
  647. year: "numeric",
  648. },
  649. // 显示农历
  650. // dayCellContent(item) {
  651. // let _date = new Date(item.date).toLocaleDateString().split("/");
  652. // let _dateF = calendar.solarToLunar(_date[0], _date[1], _date[2]);
  653. // // 以二十四节气覆盖农历日期
  654. // if (calendar.getLunar24Days(_date[0], _date[1], _date[2])) {
  655. // _dateF.dayStr = calendar.getLunar24Days(
  656. // _date[0],
  657. // _date[1],
  658. // _date[2]
  659. // );
  660. // }
  661. // return { html: `<p>${item.dayNumberText}(${_dateF.dayStr})</p>` };
  662. // },
  663. },
  664. timeGridWeek: {},
  665. timeGridDay: {},
  666. listMonth: {},
  667. },
  668. // 设置过往时间无法点击
  669. // selectAllow: function (clickInfo) {
  670. // if (clickInfo.end < new Date()) {
  671. // return false;
  672. // }
  673. // return true;
  674. // },
  675. weekends: true, //是否显示周末,设为false则不显示周六和周日
  676. selectable: true, //是否可以选中日历格
  677. editable: false, //是否可以进行(拖动、缩放)修改
  678. navLinks: true, //天链接
  679. select: this.selectDate, //选中日历格事件
  680. eventClick: this.handleEventClick, //选中备忘录事件
  681. eventsSet: this.handleEvents,
  682. events: this.getCalendarList, //获取数据源
  683. eventMouseEnter: this.eventMouseEnter, //鼠标悬浮事件
  684. slotEventOverlap: true, //相同时间段的多个日程视觉上是否允许重叠,默认true允许
  685. eventResize: this.onEventResize, // 事件时间区间调整
  686. eventDrop: this.onEventResize, // 事件Drag-Drop事件
  687. eventMouseLeave: this.eventMouseLeave, // 鼠标移出事件发生的事件
  688. },
  689. };
  690. },
  691. mounted() {
  692. this.calendarApi = this.$refs.fullCalendar.getApi();
  693. this.title = this.calendarApi.view.title;
  694. },
  695. watch: {
  696. search_input: {
  697. handler: function (newData, oldData) {
  698. if (newData == "") {
  699. this.month();
  700. this.getToday();
  701. }
  702. },
  703. deep: true,
  704. },
  705. },
  706. methods: {
  707. // 将当前时间移至今日事件
  708. today() {
  709. this.getToday();
  710. },
  711. // 月视图
  712. month() {
  713. this.calendarApi.changeView("dayGridMonth");
  714. this.title = this.calendarApi.view.title;
  715. },
  716. // 周视图
  717. week() {
  718. this.calendarApi.changeView("timeGridWeek");
  719. this.title = this.calendarApi.view.title;
  720. },
  721. // 日视图
  722. day() {
  723. this.calendarApi.changeView("timeGridDay");
  724. this.handleTime(this.calendarApi.currentData.dateProfile.activeRange);
  725. this.title = this.calendarApi.view.title;
  726. },
  727. // 列表视图
  728. list() {
  729. this.calendarApi.changeView("listMonth");
  730. this.title = this.calendarApi.view.title;
  731. },
  732. // 鼠标划过,使用tippy插件显示tooltip
  733. eventMouseEnter(info) {
  734. // 非周列表的情况下显示悬浮提示;
  735. // if (info.view.type != "listWeek") {
  736. // tippy(info.el, {
  737. // content: info.event.title,
  738. // placement: "top-start",
  739. // });
  740. // }
  741. },
  742. // 鼠标离开
  743. eventMouseLeave(arg) {
  744. // console.log("mouseleave");
  745. // arg.jsEvent.preventDefault();
  746. },
  747. // 事项调整时间区间事件
  748. onEventResize(arg) {
  749. let newTimeStart = this.dateFormat(
  750. "YYYY-mm-dd HH:MM:SS",
  751. arg.event.startStr
  752. );
  753. let newTimeEnd = this.dateFormat("YYYY-mm-dd HH:MM:SS", arg.event.endStr);
  754. this.get("/calendar/updateTime", {
  755. id: arg.event.id,
  756. Start: newTimeStart,
  757. End: newTimeEnd,
  758. }).then((res) => {
  759. this.$message.success(res.data.info);
  760. });
  761. // 必须加这句,不然切换视图会有显示事件数目的bug
  762. let calendarApi = arg.view.calendar;
  763. calendarApi.today();
  764. },
  765. // el-popover图片点击预览放大事件
  766. PreviewPic(arg) {
  767. this.dialogImageUrl = arg;
  768. this.img_dialogVisible = true;
  769. this.stopMove();
  770. },
  771. // el-popover图片点击预览后关闭事件
  772. onClose() {
  773. this.img_dialogVisible = false;
  774. this.move();
  775. },
  776. // el-popover隐藏时触发,将图片地址修改为空
  777. async popoverPicReset(arg) {
  778. this.popoverimg = await [];
  779. let calendarApi = arg.view.calendar;
  780. calendarApi.show_pic(arg);
  781. },
  782. // el-popover显示图片功能
  783. async showPic(arg) {
  784. let calendarApi = arg.view.calendar;
  785. this.popoverimg = [];
  786. await this.post("/get_img_url", arg.event.extendedProps.img, "blob").then(
  787. (res) => {
  788. // console.log(res.data.imgs);
  789. res.data.imgs.forEach((item, index) => {
  790. const img = "data:image/png;base64," + item;
  791. this.file = this.base64ImgtoFile(img); // 得到File对象
  792. const url =
  793. window.webkitURL.createObjectURL(this.file) ||
  794. window.URL.createObjectURL(this.file);
  795. this.popoverimg.push(url);
  796. });
  797. }
  798. );
  799. calendarApi.show_pic(arg);
  800. },
  801. // 提醒类别选择
  802. categorySelected(node) {
  803. this.form.categoryName = node.label;
  804. },
  805. // 自定义按钮
  806. customButton() {
  807. console.log("点击了自定义按钮");
  808. },
  809. // 今天
  810. getToday() {
  811. let calendarApi = this.$refs.fullCalendar.getApi();
  812. calendarApi.today();
  813. this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  814. this.title = this.calendarApi.view.title;
  815. this.search_input = "";
  816. },
  817. // 上一年
  818. getPrevYear() {
  819. let calendarApi = this.$refs.fullCalendar.getApi();
  820. calendarApi.prevYear();
  821. // this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  822. this.title = this.calendarApi.view.title;
  823. },
  824. // 下一年
  825. getNextYear() {
  826. let calendarApi = this.$refs.fullCalendar.getApi();
  827. calendarApi.nextYear();
  828. // this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  829. this.title = this.calendarApi.view.title;
  830. },
  831. // 上一月
  832. getPrev() {
  833. let calendarApi = this.$refs.fullCalendar.getApi();
  834. calendarApi.prev();
  835. // this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  836. this.title = this.calendarApi.view.title;
  837. },
  838. // 下一月
  839. getNext() {
  840. let calendarApi = this.$refs.fullCalendar.getApi();
  841. calendarApi.next();
  842. // this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  843. this.title = this.calendarApi.view.title;
  844. },
  845. // 处理时间格式
  846. handleTime(activeRange) {
  847. let result = {
  848. startStr: activeRange.start,
  849. endStr: activeRange.end,
  850. };
  851. this.getCalendarList();
  852. },
  853. // 获取列表信息
  854. getCalendarList(result) {
  855. // 以当前时间插入数据
  856. let _this = this;
  857. // 注意,请求的数据是数据库所有数据即可,不用考虑当前显示的时间范围,Fullcalendar会自动只显示当前日期范围的事件
  858. _this
  859. .get("/calendar/getCalendarList", "")
  860. .then((res) => {
  861. _this.calendarOptions.events = [];
  862. res.data.data.forEach((item) => {
  863. var data = {
  864. id: item[0],
  865. title: item[1],
  866. start: item[2],
  867. end: item[3],
  868. allDay: item[4],
  869. className: item[5] == true ? "borderGreen" : "borderOrange",
  870. // 非标准字段:除上述字段外,您还可以在每个事件对象中包含自己的非标准字段。FullCalendar不会修改或删除这些字段。例如,开发人员通常包括描述在回调中使用的字段,如事件呈现挂钩. 任何非标准属性都将移动到extendedProps哈希期间事件解析.
  871. extendedProps: {
  872. isDone: item[5],
  873. img: item[6],
  874. address: item[7],
  875. type: item[8],
  876. },
  877. others: "该字段值会被自动归类到extendedProps里面",
  878. backgroundColor:
  879. (item[4] == true ? "all_Day" : "other") != "all_Day"
  880. ? item[5] == true
  881. ? "#c2fccd"
  882. : "#FFECDC"
  883. : "#66b1ff",
  884. editable: true, // 是否可以进行(拖动、缩放)修改
  885. };
  886. _this.calendarOptions.events.push(data);
  887. });
  888. })
  889. .catch((error) => {
  890. this.$message.error(error);
  891. });
  892. },
  893. // 选择日期,填写事件
  894. selectDate: function (arg) {
  895. let startTime = this.dateFormat("YYYY-mm-dd HH:MM", arg.start);
  896. let endTime = this.dateFormat("YYYY-mm-dd HH:MM", arg.end);
  897. this.dialogVisible = true;
  898. this.form_edited_state = "add";
  899. this.dateRange = [startTime, endTime]; // 设置当前记录事件的选择的时间段
  900. let info = JSON.parse(localStorage.getItem("userInfo")); // 获取当前记录人信息
  901. this.form.userName = info.username; // 设置记录人
  902. this.form.isDone = "1"; // 默认设置为事件未完成状态
  903. this.form.isAllDay = arg.allDay;
  904. let calendarApi = arg.view.calendar;
  905. calendarApi.unselect(); // 清除当前日期选择
  906. },
  907. // 表单确定按钮,提交事件
  908. submitForm() {
  909. let calendarApi = this.$refs.fullCalendar.getApi();
  910. var startTime = this.dateFormat("YYYY-mm-dd HH:MM:SS", this.dateRange[0]);
  911. var endTime = this.dateFormat("YYYY-mm-dd HH:MM:SS", this.dateRange[1]);
  912. if (this.form_edited_state == "add") {
  913. // 添加事件的后端数据请求
  914. this.get(
  915. "/calendar/eventRecord",
  916. {
  917. isAllDay: this.form.isAllDay,
  918. dateRange: JSON.stringify([startTime, endTime]),
  919. remark: this.form.remark,
  920. type: this.form.type == undefined ? "" : this.form.type,
  921. isDone: this.form.isDone == "1" ? false : true,
  922. userName: this.form.userName,
  923. address: this.form.address == undefined ? "" : this.form.address,
  924. img: this.form.img == null ? "" : this.form.img,
  925. },
  926. ""
  927. ).then((res) => {
  928. this.$message.success("事件添加成功!");
  929. this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  930. });
  931. } else if (this.form_edited_state == "amend") {
  932. // 修改事件的后端数据请求
  933. this.get(
  934. "/calendar/submit",
  935. {
  936. id: this.form.id,
  937. dateRange: JSON.stringify([startTime, endTime]),
  938. remark: this.form.remark,
  939. type: this.form.type == undefined ? "" : this.form.type,
  940. isDone: this.form.isDone == "1" ? false : true,
  941. userName: this.form.userName,
  942. address: this.form.address == undefined ? "" : this.form.address,
  943. img: this.form.img == null ? "" : this.form.img,
  944. // type: this.form.category,
  945. },
  946. ""
  947. ).then((res) => {
  948. this.$message.success("修改事项成功!");
  949. if (this.search_input == "") {
  950. this.handleTime(calendarApi.currentData.dateProfile.activeRange);
  951. }
  952. });
  953. }
  954. this.dialogVisible = false;
  955. },
  956. // 表单取消按钮
  957. cancel() {
  958. this.form = {
  959. id: "",
  960. dateRange: "",
  961. remark: "",
  962. type: "",
  963. isDone: false,
  964. userName: "",
  965. address: "",
  966. img: "",
  967. };
  968. this.filelist = [];
  969. this.dialogVisible = false;
  970. this.form_edited_state = "";
  971. },
  972. // 点击事项事件
  973. handleEventClick(clickInfo) {
  974. this.dialogVisible = true;
  975. this.form_edited_state = "amend"; //修改状态
  976. var startTime = this.dateFormat(
  977. "YYYY-mm-dd HH:MM:SS",
  978. clickInfo.event.startStr
  979. );
  980. var endTime = this.dateFormat(
  981. "YYYY-mm-dd HH:MM:SS",
  982. clickInfo.event.endStr
  983. );
  984. // 设置打开对话框各部分的显示值
  985. this.form.id = clickInfo.event.id;
  986. this.dateRange = [clickInfo.event.start, clickInfo.event.end];
  987. this.form.remark = clickInfo.event.title;
  988. // 获取当前登录用户的名字
  989. let info = JSON.parse(localStorage.getItem("userInfo"));
  990. this.form.userName = info.username;
  991. this.form.isDone =
  992. clickInfo.event.extendedProps.isDone == true ? "0" : "1";
  993. this.form.img = clickInfo.event.extendedProps.img;
  994. this.form.address = clickInfo.event.extendedProps.address;
  995. this.form.category =
  996. clickInfo.event.extendedProps.type == undefined
  997. ? ""
  998. : clickInfo.event.extendedProps.type;
  999. // 请求后端图片URL方法
  1000. this.post("/get_img_url", clickInfo.event.extendedProps.img).then(
  1001. (res) => {
  1002. res.data.imgs.forEach((item, index) => {
  1003. const img = "data:image/png;base64," + item;
  1004. this.file = this.base64ImgtoFile(img); // 得到File对象
  1005. const url =
  1006. window.webkitURL.createObjectURL(this.file) ||
  1007. window.URL.createObjectURL(this.file);
  1008. this.filelist.push({
  1009. name: res.data.origin_url[index],
  1010. url: url,
  1011. });
  1012. });
  1013. }
  1014. );
  1015. },
  1016. // 事项标记已完成或改为未完成的事件
  1017. onCheckBtnClicked(arg) {
  1018. this.get(
  1019. "/calendar/checked",
  1020. { id: arg.event.id, status: arg.event.extendedProps.isDone },
  1021. ""
  1022. ).then((res) => {
  1023. this.calendarOptions.events.filter((item) => {
  1024. if (item.id == arg.event.id) {
  1025. item.extendedProps.isDone = !arg.event.extendedProps.isDone;
  1026. arg.event.extendedProps.isDone == true
  1027. ? (item.className = "borderOrange")
  1028. : (item.className = "borderGreen");
  1029. item.backgroundColor =
  1030. (arg.event.allDay == true ? "all_Day" : "other") != "all_Day"
  1031. ? arg.event.extendedProps.isDone == true
  1032. ? "#FFECDC"
  1033. : "#c2fccd"
  1034. : "#66b1ff";
  1035. }
  1036. return item;
  1037. });
  1038. this.$message.success("事件状态修改成功!");
  1039. });
  1040. },
  1041. // 事项删除事件
  1042. onRemoveBtnClicked(arg) {
  1043. this.get("/calendar/remove", arg.event.id).then((res) => {
  1044. this.calendarOptions.events = this.calendarOptions.events.filter(
  1045. (item) => {
  1046. return item.id != arg.event.id;
  1047. }
  1048. );
  1049. });
  1050. },
  1051. // 当前事件绑定,此段代码可删掉
  1052. handleEvents(events) {
  1053. this.currentEvents = events;
  1054. },
  1055. // 提交上传文件
  1056. submitFileForm() {
  1057. /* 这里为啥会先发一个Option请求再发Post请求:这是浏览器处理跨域做的逻辑。
  1058. CORS跨域请求会先发option请求,如果server返回access-control-allow-origin头为*或者和当前域名一致的话,
  1059. 才会进入第二段的真正请求。不然就会报 cross origin request is forbidden错误。*/
  1060. this.$refs.upload.submit();
  1061. },
  1062. // 对话框图片预览放大
  1063. handlePictureCardPreview(file) {
  1064. this.dialogImageUrl = [file.url];
  1065. this.img_dialogVisible = true;
  1066. },
  1067. // 预览图片下载到本地
  1068. handleDownload(file) {
  1069. // console.log(file, "@@@@");
  1070. this.get("/bbx_img_download", file.name, "blob").then((res) => {
  1071. var blob = new Blob([res.data], {
  1072. type: "application/octet-stream;chartset=UTF-8",
  1073. });
  1074. var url = window.URL.createObjectURL(blob);
  1075. var a = document.createElement("a");
  1076. a.href = url;
  1077. //文件名
  1078. let name = res.config.params.replace("F:\\flask\\upload\\", "");
  1079. a.download = name;
  1080. a.click();
  1081. window.URL.revokeObjectURL(url); // 释放掉blob对象
  1082. });
  1083. },
  1084. // 下载文件
  1085. fileDownload(file) {
  1086. // console.log(this.urlToLink(file));
  1087. // 判断是否为网页
  1088. let bool = this.urlToLink(file);
  1089. if (bool) {
  1090. var b = document.createElement("a");
  1091. b.setAttribute("href", file);
  1092. b.setAttribute("target", "_blank");
  1093. document.body.appendChild(b);
  1094. b.click();
  1095. } else {
  1096. if (file != null || file != "") {
  1097. this.get("/get_file_download", file, "blob").then((res) => {
  1098. var blob = new Blob([res.data], {
  1099. type: "application/octet-stream;chartset=UTF-8",
  1100. });
  1101. var url = window.URL.createObjectURL(blob);
  1102. var a = document.createElement("a");
  1103. a.href = url;
  1104. //文件名
  1105. let name = res.config.params.replace("F:\\flask\\upload\\", "");
  1106. a.download = name;
  1107. a.click();
  1108. window.URL.revokeObjectURL(url); // 释放掉blob对象
  1109. });
  1110. } else {
  1111. }
  1112. }
  1113. },
  1114. // 移除对话框预览图片
  1115. handleRemove(file) {
  1116. let address = this.form.img.split(",");
  1117. address = address.filter((item) => {
  1118. return item != file.name;
  1119. });
  1120. address = address.join(",");
  1121. this.form.img = address;
  1122. const newArray = this.filelist.filter((item, index) => {
  1123. return item.uid != file.uid;
  1124. });
  1125. this.filelist = newArray;
  1126. },
  1127. // 判断字符串是否为网页
  1128. urlToLink(str) {
  1129. var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  1130. if (reg.test(str)) {
  1131. return true;
  1132. } else {
  1133. return false;
  1134. }
  1135. },
  1136. // 停止页面滚动
  1137. stopMove() {
  1138. const m = (e) => {
  1139. e.preventDefault();
  1140. };
  1141. document.body.style.overflow = "hidden";
  1142. document.addEventListener("touchmove", m, false); // 禁止页面滑动
  1143. },
  1144. // 开启页面滚动
  1145. move() {
  1146. const m = (e) => {
  1147. e.preventDefault();
  1148. };
  1149. document.body.style.overflow = "auto";
  1150. document.removeEventListener("touchmove", m, true);
  1151. },
  1152. // 查询功能
  1153. onSearch() {
  1154. let search_text = this.search_input;
  1155. let curr_Events = this.calendarOptions.events;
  1156. if (search_text != "") {
  1157. this.calendarApi.changeView("list");
  1158. let result = this.searchStr(search_text, curr_Events);
  1159. this.calendarOptions.events = result;
  1160. this.title = "查询结果";
  1161. } else {
  1162. // this.today();
  1163. }
  1164. },
  1165. // 数组中匹配单个字符串的方法,传入数组支持格式[{},{}],
  1166. searchStr(str, arr) {
  1167. let newList = [];
  1168. // 要匹配字符串的首个字符
  1169. let startChar = str.charAt(0);
  1170. // 要匹配字符串的字符长度
  1171. let strLength = str.length;
  1172. for (let i = 0; i < arr.length; i++) {
  1173. // 默认数组arr中对象arr[i]不存在str
  1174. let isExist = false;
  1175. let obj = arr[i];
  1176. for (let key in obj) {
  1177. if (typeof obj[key] === "function") {
  1178. obj[key]();
  1179. } else {
  1180. let keyValue = "";
  1181. // 获取arr[i][key]的值
  1182. if (obj[key] !== null && typeof obj[key] === "string") {
  1183. keyValue = obj[key];
  1184. } else if (obj[key] !== null && typeof obj[key] !== "string") {
  1185. keyValue = JSON.stringify(obj[key]);
  1186. }
  1187. // arr[i][key]中的各个位置的字符与str的0位置字符startChar对比如果相等,
  1188. // 在arr[i][key]中从j位置截取与str长度相同的字符,对比是否相等
  1189. for (let j = 0; j < keyValue.length; j++) {
  1190. // 把原有数据转化为小写,输入数据也转化为纯小写,实现模糊匹配,如区分大小写,可删除toLowerCase()
  1191. if (
  1192. keyValue.charAt(j).toLowerCase() === startChar.toLowerCase()
  1193. ) {
  1194. if (
  1195. keyValue
  1196. .substring(j)
  1197. .substring(0, strLength)
  1198. .toLowerCase() === str.toLowerCase()
  1199. ) {
  1200. // 模糊匹配到的字符存在表示arr[i]中存在str
  1201. isExist = true;
  1202. break;
  1203. }
  1204. }
  1205. }
  1206. }
  1207. }
  1208. // 当arr[i]中存在str时,把arr[i]放入一个新数组
  1209. if (isExist === true) {
  1210. newList.push(obj);
  1211. }
  1212. }
  1213. // 最后返回这个新数组
  1214. return newList;
  1215. },
  1216. // 格式化时间 fmt是所需格式化的格式,如"YYYY-mm-dd HH:MM:SS",date是所需格式化的日期
  1217. dateFormat(fmt, date) {
  1218. let ret = "";
  1219. date = new Date(date);
  1220. const opt = {
  1221. "Y+": date.getFullYear().toString(), // 年
  1222. "m+": (date.getMonth() + 1).toString(), // 月
  1223. "d+": date.getDate().toString(), // 日
  1224. "H+": date.getHours().toString(), // 时
  1225. "M+": date.getMinutes().toString(), // 分
  1226. "S+": date.getSeconds().toString(), // 秒
  1227. };
  1228. for (let k in opt) {
  1229. ret = new RegExp("(" + k + ")").exec(fmt);
  1230. if (ret) {
  1231. fmt = fmt.replace(
  1232. ret[1],
  1233. ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
  1234. );
  1235. }
  1236. }
  1237. return fmt;
  1238. },
  1239. //日期格式转换
  1240. formatTimer: function (value) {
  1241. let date = new Date(value);
  1242. let y = date.getFullYear();
  1243. let MM = date.getMonth() + 1;
  1244. MM = MM < 10 ? "0" + MM : MM;
  1245. let d = date.getDate();
  1246. d = d < 10 ? "0" + d : d;
  1247. let h = date.getHours();
  1248. h = h < 10 ? "0" + h : h;
  1249. let m = date.getMinutes();
  1250. m = m < 10 ? "0" + m : m;
  1251. let s = date.getSeconds();
  1252. s = s < 10 ? "0" + s : s;
  1253. return h + ":" + m;
  1254. },
  1255. // 获取当前时间戳
  1256. getCurrentTime() {
  1257. let date = new Date();
  1258. let year = date.getFullYear();
  1259. let month = date.getMonth() + 1;
  1260. let day = date.getDate();
  1261. let hour = date.getHours();
  1262. let minute = date.getMinutes();
  1263. let second = date.getSeconds();
  1264. month = month < 10 ? "0" + month : month; // 可注释掉
  1265. day = day < 10 ? "0" + day : day;
  1266. hour = hour < 10 ? "0" + hour : hour; // 可注释掉
  1267. minute = minute < 10 ? "0" + minute : minute;
  1268. second = second < 10 ? "0" + second : second;
  1269. return `${year}/${month}/${day} ${hour}:${minute}:${second}`;
  1270. },
  1271. // 地址上传地址
  1272. address_beforeupload(file, filelist) {
  1273. let formData = new FormData();
  1274. formData.append("file", file.raw);
  1275. this.upload("/get_file_url", formData, "").then((res) => {
  1276. this.form.address = res.data.path;
  1277. });
  1278. },
  1279. /** 图片上传功能 */
  1280. beforeupload(file, filelist) {
  1281. this.filelist = filelist;
  1282. let formData = new FormData();
  1283. formData.append("file", file.raw);
  1284. // 请求数据
  1285. this.upload("/get_file_url", formData, "").then((res) => {
  1286. if (this.form.img == null) {
  1287. this.form.img = res.data.path;
  1288. } else {
  1289. this.form.img = this.form.img + "," + res.data.path;
  1290. }
  1291. });
  1292. },
  1293. // base64字段变成blob二进制数据,关于图片的
  1294. base64ImgtoFile(dataurl, filename = "file") {
  1295. const arr = dataurl.split(",");
  1296. const mime = arr[0].match(/:(.*?);/)[1];
  1297. const suffix = mime.split("/")[1];
  1298. const bstr = atob(arr[1]);
  1299. let n = bstr.length;
  1300. const u8arr = new Uint8Array(n);
  1301. while (n--) {
  1302. u8arr[n] = bstr.charCodeAt(n);
  1303. }
  1304. return new File([u8arr], `${filename}.${suffix}`, {
  1305. type: mime,
  1306. });
  1307. },
  1308. },
  1309. };
  1310. </script>
  1311. <!-- 样式1,本地样式 -->
  1312. <style lang="scss" scoped>
  1313. .calendar_matters >>> .el-dialog__body {
  1314. height: 450px;
  1315. overflow: auto;
  1316. }
  1317. .calendar_details >>> .el-textarea__inner {
  1318. font-weight: bold;
  1319. font-family: Arial, Helvetica, sans-serif;
  1320. color: #000;
  1321. height: 120px;
  1322. }
  1323. .calendar_matters >>> .el-dialog__header {
  1324. border-radius: 5px;
  1325. background-color: #cae1f7;
  1326. align-content: center;
  1327. padding: 15px;
  1328. font-weight: bold;
  1329. border-bottom-style: solid;
  1330. border-bottom-width: 1px;
  1331. border-bottom-color: aliceblue;
  1332. }
  1333. .fc-daygrid-day-top p {
  1334. font-size: 13px;
  1335. color: #606266;
  1336. margin-right: 10px;
  1337. }
  1338. .fc .fc-toolbar.fc-header-toolbar {
  1339. margin-bottom: 10px;
  1340. }
  1341. .el-main {
  1342. padding: 8px 10px 8px 10px;
  1343. }
  1344. .userName >>> .el-input__inner {
  1345. font-weight: bold;
  1346. color: #000000ab;
  1347. }
  1348. .attachment >>> .el-form-item__content {
  1349. display: flex;
  1350. }
  1351. .upload-demo >>> .el-upload-list--picture-card .el-upload-list__item {
  1352. height: 120px;
  1353. width: 120px;
  1354. }
  1355. .upload-demo >>> .el-upload--picture-card {
  1356. height: 120px;
  1357. width: 120px;
  1358. line-height: 120px;
  1359. }
  1360. .dateRange >>> .el-range-input {
  1361. font-weight: bold;
  1362. color: #080808;
  1363. }
  1364. .calendar >>> .fc-header-toolbar {
  1365. margin-bottom: 5px;
  1366. }
  1367. .calendar >>> .borderGreen {
  1368. border-left: 5px solid #44bb08 !important;
  1369. border-radius: 0;
  1370. border: none;
  1371. white-space: normal;
  1372. overflow: hidden;
  1373. text-overflow: ellipsis;
  1374. span {
  1375. color: #000;
  1376. font-weight: bold;
  1377. }
  1378. }
  1379. .calendar >>> .borderOrange {
  1380. border-left: 5px solid #fe9b02 !important;
  1381. border-radius: 0;
  1382. border: none;
  1383. white-space: normal;
  1384. overflow: hidden;
  1385. span {
  1386. color: #000;
  1387. font-weight: bold;
  1388. }
  1389. }
  1390. .calendar >>> .borderOrigin {
  1391. border-radius: 0;
  1392. border: none;
  1393. white-space: normal;
  1394. overflow: hidden;
  1395. text-overflow: ellipsis;
  1396. max-height: 150px;
  1397. span {
  1398. color: #000;
  1399. font-weight: bold;
  1400. }
  1401. }
  1402. .calendar >>> .fc-event-title {
  1403. font-weight: bold;
  1404. color: #000;
  1405. overflow: hidden;
  1406. }
  1407. .calendar >>> .fc-event-time {
  1408. font-weight: bold;
  1409. color: #000;
  1410. }
  1411. .calendar >>> .fc-daygrid-event-dot {
  1412. border: none;
  1413. }
  1414. .popover {
  1415. .el-popover {
  1416. max-height: 350px;
  1417. }
  1418. }
  1419. .popover_title {
  1420. font-weight: bold;
  1421. margin-bottom: 3px;
  1422. }
  1423. .popover_content {
  1424. color: #000;
  1425. font-size: 13px;
  1426. }
  1427. .popoverShowImg {
  1428. width: auto;
  1429. cursor: pointer;
  1430. >>> .el-image__inner {
  1431. max-height: 200px;
  1432. }
  1433. }
  1434. .link {
  1435. color: #000;
  1436. font-size: 12px;
  1437. font-weight: bold;
  1438. margin-top: 2px;
  1439. & :hove {
  1440. color: #66b1ff;
  1441. }
  1442. }
  1443. .fc_btns {
  1444. padding: 10px 12px;
  1445. }
  1446. .el-icon-search {
  1447. line-height: 2.5;
  1448. margin-right: 8px;
  1449. }
  1450. .fc-right {
  1451. display: flex;
  1452. flex: 1.5;
  1453. justify-content: flex-end;
  1454. }
  1455. .tip-content {
  1456. line-height: 2.2;
  1457. margin-right: 4px;
  1458. font-weight: 600;
  1459. }
  1460. .title {
  1461. margin: 0px 5px;
  1462. line-height: 1.6;
  1463. }
  1464. .calendar_matters {
  1465. width: 100%;
  1466. }
  1467. .calendar >>> .el-popover__reference {
  1468. display: grid;
  1469. max-height: 150px;
  1470. overflow: auto;
  1471. }
  1472. </style>
  1473. <!-- 样式2 -->
  1474. <style>
  1475. .el-popover__reference::-webkit-scrollbar {
  1476. /*滚动条整体样式*/
  1477. width: 8px; /*高宽分别对应横竖滚动条的尺寸*/
  1478. height: 1px;
  1479. }
  1480. .el-popover__reference::-webkit-scrollbar-thumb {
  1481. /*滚动条里面小方块*/
  1482. border-radius: 10px;
  1483. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  1484. background: #535353;
  1485. }
  1486. .el-popover__reference::-webkit-scrollbar-track {
  1487. /*滚动条里面轨道*/
  1488. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  1489. border-radius: 2px;
  1490. background: #ededed;
  1491. }
  1492. .popover .el-popover__title {
  1493. font-weight: bold;
  1494. margin-bottom: 5px;
  1495. border-bottom: solid 1px;
  1496. padding: 2px;
  1497. }
  1498. @media only screen and (max-width: 767px) {
  1499. .fc-toolbar {
  1500. flex-direction: column;
  1501. }
  1502. .fc-left {
  1503. flex: 1 !important;
  1504. }
  1505. .tips {
  1506. flex: 1 !important;
  1507. justify-content: center;
  1508. margin-bottom: 5px;
  1509. }
  1510. .fc-center {
  1511. flex: 1 !important;
  1512. margin: 5px 0px;
  1513. }
  1514. .fc-right {
  1515. flex: 1;
  1516. justify-content: center !important;
  1517. margin-bottom: 5px;
  1518. }
  1519. .tip-content {
  1520. line-height: 1 !important;
  1521. margin-right: 4px;
  1522. font-weight: 600;
  1523. }
  1524. .title {
  1525. font-size: 20px;
  1526. font-weight: 700;
  1527. line-height: 1.9 !important;
  1528. }
  1529. .fc-list-table {
  1530. word-break: break-all;
  1531. overflow: auto;
  1532. }
  1533. .fc-list-event-title {
  1534. overflow: auto;
  1535. }
  1536. .el-dialog {
  1537. width: 90%;
  1538. }
  1539. .dateRange {
  1540. overflow: auto;
  1541. }
  1542. }
  1543. </style>

5、 后端Flask源码

  1. from flask import Flask, render_template,\
  2. request, jsonify, make_response, Response, send_file,session,send_from_directory
  3. from flask_cors import CORS
  4. import datetime
  5. import json
  6. import pypyodbc
  7. from collections import deque
  8. import os
  9. import base64
  10. import hashlib
  11. import xlwt
  12. import openpyxl
  13. import xlrd
  14. app = Flask(__name__,
  15. static_folder='./templates/static', # 设置静态文件夹目录
  16. template_folder="./templates") # 设置vue编译输出目录dist文件夹,为Flask模板文件目录
  17. # 解决后端跨域问题,不然会在前端网页控制台显示“ccess to XMLHttpRequest at 'http://localhost:8080/api/login' from origin 'null' has been blocked”
  18. CORS(app, supports_credentials=True)
  19. session = {}
  20. @app.route('/')
  21. def index():
  22. return render_template('index.html',name='index') #使用模板插件,引入index.html。此处会自动Flask模板文件目录寻找index.html文件。
  23. @app.route('/calendar/eventRecord', methods=["GET", "POST"])
  24. def calendar_evnetRecord():
  25. params = request.values
  26. date = json.loads(params["dateRange"])
  27. startTime = datetime.datetime.strptime(date[0],"%Y-%m-%d %H:%M:%S")
  28. endTime = datetime.datetime.strptime(date[1],"%Y-%m-%d %H:%M:%S")
  29. # print(params)
  30. conn = get_conn()
  31. cur = conn.cursor()
  32. sql = "insert into 记事本(allDay, startStr,endStr, title, type, isDone, userName,img,address) values(%s, '%s','%s','%s','%s',%s,'%s','%s','%s')" \
  33. %(params["isAllDay"],startTime,endTime,params["remark"],params["type"],params["isDone"],params["userName"],params["img"],params["address"])
  34. cur.execute(sql)
  35. cur.commit()
  36. cur.close()
  37. conn.close()
  38. return jsonify({"code":200})
  39. @app.route('/calendar/getCalendarList', methods=["GET", "POST"])
  40. def calendar_getCalendarList():
  41. params = request.values
  42. conn = get_conn()
  43. cur = conn.cursor()
  44. sql = "select ID,title,Format(startStr, 'yyyy-MM-dd HH:mm:ss'),Format(endStr, 'yyyy-MM-dd HH:mm:ss'),allDay,isDone,img,address,type " \
  45. "from 记事本 "
  46. cur.execute(sql)
  47. data = cur.fetchall()
  48. cur.close()
  49. conn.close()
  50. return jsonify({"code":200,"data":data})
  51. @app.route('/calendar/submit', methods=["GET", "POST"])
  52. def calendar_submit():
  53. params = request.values
  54. date = json.loads(params["dateRange"])
  55. startTime = datetime.datetime.strptime(date[0],"%Y-%m-%d %H:%M:%S")
  56. endTime = datetime.datetime.strptime(date[1],"%Y-%m-%d %H:%M:%S")
  57. conn = get_conn()
  58. cur = conn.cursor()
  59. sql="update 记事本 set startStr='%s',endStr='%s',title='%s',type='%s',isDone=%s,userName='%s',img='%s',address='%s' where ID=%s"\
  60. %(startTime,endTime,params["remark"],params["type"],params["isDone"],params["userName"],params["img"],params["address"]
  61. ,params["id"])
  62. cur.execute(sql)
  63. cur.commit()
  64. cur.close()
  65. conn.close()
  66. return jsonify({"code":200})
  67. @app.route('/calendar/checked', methods=["GET", "POST"])
  68. def calendar_checked():
  69. params = request.values
  70. status = True if params["status"] == "false" else False
  71. conn = get_conn()
  72. cur = conn.cursor()
  73. sql = "update 记事本 set isDone=%s where ID=%s" %(status,params["id"])
  74. cur.execute(sql)
  75. cur.commit()
  76. cur.close()
  77. conn.close()
  78. return jsonify({"code": 200, "info":"状态修改成功!"})
  79. @app.route('/calendar/remove', methods=["GET", "POST"])
  80. def calendar_remove():
  81. matters_id = request.values.get("0")
  82. conn = get_conn()
  83. cur = conn.cursor()
  84. sql = "delete from 记事本 where ID=%s" % (matters_id)
  85. try:
  86. cur.execute(sql)
  87. cur.commit()
  88. return jsonify({"code": 200, "info":"删除成功!"})
  89. except Exception as e:
  90. return jsonify({"code": 200, "info":"发生错误!错误代码:"+str(e)})
  91. finally:
  92. cur.close()
  93. conn.close()
  94. @app.route('/calendar/updateTime', methods=["GET", "POST"])
  95. def calendar_updateTime():
  96. params = request.values
  97. conn = get_conn()
  98. cur = conn.cursor()
  99. sql = "update 记事本 set startStr='%s',endStr='%s' where ID=%s" %(params["Start"],params["End"],params["id"])
  100. cur.execute(sql)
  101. cur.commit()
  102. cur.close()
  103. conn.close()
  104. return jsonify({"code": 200, "info": "事件时间修改成功!"})
  105. @app.route('/get_file_download', methods=["GET", "POST"])
  106. def get_file_download():
  107. file_url = request.values.get("0")
  108. with open(file_url, 'rb') as file_f:
  109. res = make_response(file_f.read()) # 用flask提供的make_response 方法来自定义自己的response对象
  110. # res.headers['Content-Type'] = 'image/jpg' # 设置response对象的请求头属性'Content-Type'为图片格式
  111. return res
  112. if __name__ == '__main__':
  113. # 0.0.0.0 表示同一个局域网均可访问,也可以替换成本机地址:通过命令行命令:ipcofig 获取
  114. app.run(host='0.0.0.0', port='5000', debug=True)

6 、数据库数据(ACCESS)格式

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发