liu_other.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="content">
  3. <!-- 切换发起提交与提交记录 -->
  4. <view class="select-type" v-if="liutype" @click="changeType">
  5. <view class="allday">发起提交</view>
  6. <view class="hourday_no">提交记录</view>
  7. </view>
  8. <view class="select-type" v-else @click="changeType">
  9. <view class="allday2">发起提交</view>
  10. <view class="hourday_no2">提交记录</view>
  11. </view>
  12. <!-- 发起提交各选项表单 -->
  13. <view v-if="liutype">
  14. <view class="submit">
  15. <!-- 基础表单校验 -->
  16. <uni-forms ref="valiForm" :rules="rules" :modelValue="baseFormData">
  17. <uni-forms-item label="类型" name="companyName" required>
  18. <!-- <picker :range="baseFormData.submittype"> -->
  19. <view class="uni-input" style="margin-right: 40px;color: black;">
  20. <template>临时人员</template>
  21. <!-- <template v-else>{{baseFormData.submittype[baseFormData.indextype]}}</template>
  22. <text class="jiantou">〉</text> -->
  23. </view>
  24. <!-- </picker> -->
  25. </uni-forms-item>
  26. <view class="form-line"></view>
  27. <uni-forms-item label="开始时间" name="companyName" required>
  28. <uni-datetime-picker type="dateTime" return-type="datetime" @change="changeStartTime" v-model="baseFormData.startTime" :start="baseFormData.mindate"/>
  29. </uni-forms-item>
  30. <view class="form-line"></view>
  31. <uni-forms-item label="结束时间" name="companyName" required>
  32. <uni-datetime-picker type="date" return-type="datetime" @change="changeEndTime" v-model="baseFormData.endTime" :start="baseFormData.mindate"/>
  33. </uni-forms-item>
  34. <view class="form-line"></view>
  35. <uni-forms-item label="申请部门" name="companyName" required>
  36. <view class="uni-input" style="margin-right: 40px;color: black;">
  37. <!-- <template v-if="baseFormData.indextype==null">请选择</template> -->
  38. <template>
  39. <template v-if="baseFormData.bumen=='0'">其他</template>
  40. <template v-if="baseFormData.bumen=='1'">学生</template>
  41. <template v-if="baseFormData.bumen=='4'">教职工</template>
  42. <template v-if="baseFormData.bumen=='5'">校友</template>
  43. <template v-if="baseFormData.bumen=='6'">访客</template>
  44. <template v-if="baseFormData.bumen=='7'">临时人员</template>
  45. </template>
  46. <!-- <text class="jiantou">〉</text> -->
  47. </view>
  48. </uni-forms-item>
  49. <view style="width: 750rpx;height: 20rpx;background-color: rgba(242, 243, 245, 1);margin-left: -20px;"></view>
  50. <uni-forms-item label="备注" name="companyName" required>
  51. </uni-forms-item>
  52. <uni-easyinput type="textarea" v-model="baseFormData.remark" placeholder="请输入备注" maxlength="800" @input="input"></uni-easyinput>
  53. <text class="textsrea-txt">{{textNum}}/800</text>
  54. <view style="width:100%;height: 30px;"></view>
  55. </uni-forms>
  56. </view>
  57. <view class="submit_button" @click="submitshen">提交</view>
  58. </view>
  59. <!-- 提交记录 -->
  60. <view v-else>
  61. <view class="select_submit">
  62. <view style="width: 80px;margin-left: 9rpx;position: absolute;">
  63. <uni-data-select
  64. v-model="value"
  65. :localdata="zhuangtai"
  66. @change="changezhuang"
  67. ></uni-data-select>
  68. </view>
  69. <view style="width: 80px;margin-left: 196rpx;">
  70. <uni-data-select
  71. v-model="value2"
  72. :localdata="TimeRanges"
  73. @change="changetime"
  74. ></uni-data-select>
  75. </view>
  76. <!-- 不同状态的记录 -->
  77. <view class="submit-list" v-for="(item,index) in submit" :key="index" @click="clickDetail(item.id,item.department)">
  78. <text class="submit-title">临时人员</text>
  79. <text class="submit-time">{{item.submissionTime}}</text>
  80. <view class="submit-line"></view>
  81. <view class="submit-start">开始时间:{{item.startTime}}</view>
  82. <view class="submit-end">结束时间:{{item.endTime}}</view>
  83. <view class="submit-remark">备注:{{item.reasonApplication}}</view>
  84. <view class="submit-type1" v-if="item.status==0">已拒绝</view>
  85. <view class="submit-type1" v-if="item.status==1">待审批</view>
  86. <view class="submit-type2" v-if="item.status==2">处理中</view>
  87. <view class="submit-type" v-if="item.status==3">已同意</view>
  88. </view>
  89. </view>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import {
  95. postLingshi,
  96. getOtherlist
  97. } from '../../utils/api_hotel.js'
  98. export default {
  99. data() {
  100. return {
  101. liutype:true,//切换流程状态
  102. //表单数据
  103. baseFormData:{
  104. startTime:'',
  105. endTime:'',
  106. mindate:new Date().toISOString().slice(0, 10),
  107. remark:'',//备注
  108. bumen:localStorage.getItem('department'),
  109. },
  110. textNum:0,
  111. // 校验规则
  112. rules: {
  113. age: {
  114. rules: [{
  115. required: true,
  116. errorMessage: '年龄不能为空'
  117. }, {
  118. format: 'number',
  119. errorMessage: '年龄只能输入数字'
  120. }]
  121. }
  122. },
  123. // 提交记录
  124. value: '',
  125. zhuangtai: [
  126. { value: 0, text: "已拒绝" },
  127. { value: 1, text: "待审批" },
  128. { value: 2, text: "处理中" },
  129. { value: 3, text: "已同意" },
  130. { value: '', text: "全部" },
  131. ],
  132. value2: 2,
  133. TimeRanges: [
  134. { value: 0, text: "近一周" },
  135. { value: 1, text: "本月" },
  136. { value: 2, text: "全部" },
  137. ],
  138. submit:[],
  139. page:1,
  140. size:10,
  141. startTime:'',
  142. endTime:'',
  143. nowTime: new Date().toISOString().slice(0, 10),//当前日期2024-07-23
  144. totalCount:0,
  145. }
  146. },
  147. onLoad() {
  148. },
  149. mounted() {
  150. },
  151. methods: {
  152. //切换
  153. changeType(){
  154. this.liutype=!this.liutype
  155. if(this.liutype==false){
  156. this.getOtherlist()
  157. }
  158. },
  159. //输入备注
  160. input(e){
  161. this.baseFormData.remark=e
  162. this.textNum=e.length
  163. },
  164. changeStartTime(e){
  165. this.baseFormData.startTime=e
  166. },
  167. changeEndTime(e){
  168. this.baseFormData.endTime=e
  169. },
  170. //提交审核
  171. submitshen(){
  172. if(this.baseFormData.endTime<=this.baseFormData.startTime){
  173. uni.showToast({
  174. title: '开始时间不能大于结束时间',
  175. icon: 'error',
  176. duration: 1000
  177. })
  178. return
  179. }
  180. let _self = this
  181. this.$axios.defaults.headers.common['token'] = localStorage.getItem('token');
  182. this.$axios.defaults.headers.common['request_token'] = this.submitToken;
  183. this.$axios.defaults.headers.common['Content-Type'] ='application/json'
  184. var data={
  185. "usersId": localStorage.getItem('usersId'), //申请人id
  186. "startTime": this.baseFormData.startTime, //开始时间
  187. "endTime": this.baseFormData.endTime, //结束时间
  188. "department": localStorage.getItem('department'), //部门
  189. "reasonApplication": this.baseFormData.remark ,//申请原因
  190. }
  191. postLingshi(data).then((res) => {
  192. if (res.success) {
  193. uni.showToast({
  194. title: '提交成功',
  195. icon: 'success',
  196. duration: 1000
  197. })
  198. this.liutype=false
  199. this.getOtherlist()
  200. // setTimeout(function() {
  201. // this.liutype=false
  202. // // uni.switchTab({
  203. // // url:'/pages/myself/myself'
  204. // // })
  205. // }, 2000);
  206. } else {
  207. }
  208. }).catch((err) => {
  209. uni.showToast({
  210. title: err.message
  211. })
  212. });
  213. },
  214. // 临时人员提交记录
  215. getOtherlist(){
  216. let _self = this
  217. // adminMenuId身份类型,4为教职工,7为临时人员localStorage.getItem('department')
  218. // 状态,0:已拒绝,1:待审批,2:处理中,3:已同意
  219. var data="?department="+localStorage.getItem('department')+"&userId=13"+"&startTime="+this.startTime+"&endTime="+this.endTime+"&status="+this.value+"&page="+this.page+"&size="+this.size
  220. getOtherlist(data).then((res) => {
  221. if (res.success) {
  222. this.totalCount=res.data.totalCount
  223. if (this.page == 1) {
  224. this.submit = res.data.list
  225. } else {
  226. this.submit = [...this.submit, ...res.data.list]
  227. }
  228. uni.stopPullDownRefresh();
  229. uni.hideLoading()
  230. } else {
  231. console.log('获取记录失败')
  232. }
  233. }).catch((err) => {
  234. uni.showToast({
  235. title: err.message
  236. })
  237. });
  238. },
  239. onReachBottom: function() {
  240. console.log('当前长度',this.submit.length,this.totalCount)
  241. if (this.submit.length < this.totalCount) {
  242. wx.showLoading({
  243. title: '加载中...',
  244. })
  245. this.page = this.page + 1;
  246. this.getOtherlist()
  247. } else {
  248. // uni.showToast({
  249. // title: '已经到底了',
  250. // icon: 'none'
  251. // })
  252. }
  253. },
  254. onPullDownRefresh: function() {
  255. this.page = 1;
  256. this.getOtherlist();
  257. },
  258. // 选择审批状态
  259. changezhuang(e) {
  260. this.value=e
  261. this.getOtherlist()
  262. },
  263. //获得本周的开始时间:
  264. getStartDayOfWeek(time) {
  265. let now = new Date(time); // 当前日期
  266. let nowDayOfWeek = now.getDay(); // 今天本周的第几天
  267. let day = nowDayOfWeek || 7;
  268. let nowDay = now.getDate(); // 当前日
  269. let nowMonth = now.getMonth(); // 当前月
  270. return this.formatDate(new Date(now.getFullYear(), nowMonth, nowDay + 1 - day));
  271. },
  272. //获得本周的结束时间:
  273. getEndDayOfWeek(time) {
  274. let now = new Date(time); // 当前日期
  275. let nowDayOfWeek = now.getDay(); // 今天本周的第几天
  276. let day = nowDayOfWeek || 7;
  277. let nowDay = now.getDate(); // 当前日
  278. let nowMonth = now.getMonth(); // 当前月
  279. return this.formatDate(new Date(now.getFullYear(), nowMonth, nowDay + 7 - day));
  280. },
  281. //获得本月的开始时间:
  282. getStartDayOfMonth(time) {
  283. let now = new Date(time); // 当前日期
  284. let nowDay = now.getDate(); // 当前日
  285. let nowMonth = now.getMonth(); // 当前月
  286. return this.formatDate(new Date(now.getFullYear(), nowMonth, 1));
  287. },
  288. // 日期格式化
  289. formatDate(date) {
  290. let myyear = date.getFullYear();
  291. let mymonth = date.getMonth() + 1;
  292. let myweekday = date.getDate();
  293. if (mymonth < 10) {
  294. mymonth = '0' + mymonth;
  295. }
  296. if (myweekday < 10) {
  297. myweekday = '0' + myweekday;
  298. }
  299. return (myyear + '-' + mymonth + '-' + myweekday);
  300. },
  301. // 选择时间
  302. changetime(e) {
  303. this.value2=e
  304. if(this.value2==0){
  305. this.startTime=this.getStartDayOfWeek(this.nowTime).slice(0, 10)+' 00:00:00'
  306. this.endTime=this.getEndDayOfWeek(this.nowTime).slice(0, 10)+' 23:59:59'
  307. }else if(this.value2==1){
  308. this.startTime=this.getStartDayOfMonth(this.nowTime).slice(0, 10)+' 00:00:00'
  309. this.endTime=this.nowTime+' 23:59:59'
  310. }else if(this.value2==2){
  311. this.startTime=''
  312. this.endTime=''
  313. }
  314. this.getOtherlist()
  315. },
  316. // 跳转到详情页面
  317. clickDetail(id,department){
  318. uni.navigateTo({
  319. url: "../liuchengO/detail/teach_detail?id="+id+"&department="+department
  320. })
  321. }
  322. }
  323. }
  324. </script>
  325. <style>
  326. @import url("./css/liu_other.css");
  327. </style>