dayForm.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <view class="wrapper" style="padding: 30px">
  3. <div class="header">
  4. <div>
  5. <h2 v-if="!isOffDuty">每日上岗</h2>
  6. </div>
  7. <div style="position: absolute;padding: 5px 20px;font-size: 15px;color: rgba(0,0,0,0.39);
  8. right: 10px;top:10px;border: 1px solid rgba(0,0,0,0.39);border-radius: 10px">
  9. <span>{{form.orgName}}</span>
  10. </div>
  11. </div>
  12. <view class="main">
  13. <view>
  14. <text class="u-block__title" style="font-size: 18px;">{{1+'.'+text[0].label}}</text>
  15. <view class="u-demo-block__content" style="padding: 15px;">
  16. <view class="u-page__radio-item">
  17. <u-radio-group v-model="form.queResults[0]" placement="column" activeColor="#73a6a4">
  18. <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in text[0].resultList"
  19. :key="item.id" :label="item.value" :name="item.value" size="25">
  20. </u-radio>
  21. </u-radio-group>
  22. </view>
  23. </view>
  24. <view>
  25. </view>
  26. <view class="uni-list" v-if="form.queResults[0] === '是'">
  27. <view class="uni-list-cell">
  28. <view class="uni-list-cell-left">
  29. <span style="font-size: 16px;color: #acacac;">
  30. 开始时间:
  31. </span>
  32. </view>
  33. <view class="uni-list-cell-db">
  34. <view class="example-body">
  35. <uni-datetime-picker type="datetime" :border="false" :clear-icon="false"
  36. return-type="timestamp" :start="Date.now()" v-model="form.vacateStartTime" />
  37. </view>
  38. <!-- <picker mode="date" :value="form.vacateStartTime" :start="startDate" :end="endDate"
  39. @change="bindStartDateChange">
  40. <view class="uni-input">{{form.vacateStartTime}}</view>
  41. </picker> -->
  42. </view>
  43. </view>
  44. <view class="uni-list-cell">
  45. <view class="uni-list-cell-left">
  46. <span style="font-size: 16px;color: #acacac;">
  47. 结束时间:
  48. </span>
  49. </view>
  50. <view class="uni-list-cell-db">
  51. <view class="example-body">
  52. <uni-datetime-picker type="datetime" :border="false" :clear-icon="false"
  53. return-type="timestamp" :start="Date.now()" v-model="form.vacateEndTime" />
  54. </view>
  55. <!-- <picker mode="date" :value="form.vacateEndTime" :start="startDate" :end="endDate"
  56. @change="bindEndDateChange">
  57. <view class="uni-input">{{form.vacateEndTime}}</view>
  58. </picker> -->
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view>
  64. <text class="u-block__title" style="font-size: 18px;">{{1+'.'+text[1 ].label}}</text>
  65. <view class="u-demo-block__content" style="padding: 15px;">
  66. <view class="u-page__radio-item">
  67. <u-radio-group v-model="form.queResults[1]" placement="column" activeColor="#73a6a4">
  68. <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in text[1].resultList"
  69. :key="item.id" :label="item.value" :name="item.value" size="25">
  70. </u-radio>
  71. </u-radio-group>
  72. </view>
  73. </view>
  74. </view>
  75. <view>
  76. <text class="u-block__title" style="font-size: 18px;">{{1+'.'+text[2].label}}</text>
  77. <view class="u-demo-block__content" style="padding: 15px;">
  78. <view class="u-page__radio-item">
  79. <u-radio-group v-model="form.queResults[2]" placement="column" activeColor="#73a6a4">
  80. <u-radio :customStyle="{marginBottom: '8px'}" v-for="(item, index) in text[2].resultList"
  81. :key="item.id" :label="item.value" :name="item.value" size="25">
  82. </u-radio>
  83. </u-radio-group>
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. <view>
  89. <u-button v-if="!isOffDuty" type="success" @click="submit" color="#73a6a4" :disabled="disabled">
  90. 上班提交
  91. </u-button>
  92. <view v-if="isOffDuty" style="">
  93. <u-text text="说明:"></u-text>
  94. <view style="border: 1px solid #d5d5d5; margin:5px 0 50px 0;">
  95. <u-textarea v-model="form.remark" placeholder="请输入内容" count></u-textarea>
  96. </view>
  97. <u-button style="font-size: 24px;" type="success" @click="submit" color="#73a6a4" :disabled="disabled">
  98. 下班打卡
  99. </u-button>
  100. </view>
  101. </view>
  102. <view class="uni-fixed-bottom">
  103. <div style="margin-bottom: 5px;">
  104. <u-row>
  105. <u-col span="5">
  106. <u-text text="技术支持:会山科技" color="#cacaca">
  107. </u-text>
  108. </u-col>
  109. <u-col span="2">
  110. <div></div>
  111. </u-col>
  112. <u-col span="5">
  113. <u-text text="hs@willalp.com" color="#cacaca">
  114. </u-text>
  115. </u-col>
  116. </u-row>
  117. </div>
  118. </view>
  119. </view>
  120. </template>
  121. <script>
  122. export default {
  123. name: "form",
  124. data() {
  125. const currentDate = this.getDate({
  126. format: true
  127. })
  128. return {
  129. text: [{
  130. "id": "1509390250483634177",
  131. "label": "是否请假",
  132. "prop": "queResultText1",
  133. "resultList": [{
  134. "value": "是",
  135. "id": "1"
  136. },
  137. {
  138. "value": "否",
  139. "id": "2"
  140. }
  141. ]
  142. }, {
  143. "id": "1519272021753278466",
  144. "label": "是否晚班",
  145. "prop": "queResultText2",
  146. "resultList": [{
  147. "value": "是",
  148. "id": "1"
  149. },
  150. {
  151. "value": "否",
  152. "id": "2"
  153. }
  154. ]
  155. }, {
  156. "id": "1523961554814062594",
  157. "label": "是否被管控",
  158. "prop": "queResultText3",
  159. "resultList": [{
  160. "value": "是",
  161. "id": "1"
  162. },
  163. {
  164. "value": "否",
  165. "id": "2"
  166. }
  167. ]
  168. }],
  169. queDbList: [],
  170. disabled: false,
  171. isOffDuty: false,
  172. form: {
  173. userName: '',
  174. userNo: '',
  175. orgNo: '',
  176. orgName: '',
  177. clockInType: 0,
  178. vacateStartTime: '',
  179. vacateEndTime: '',
  180. remark: '',
  181. queResults: [],
  182. ques: []
  183. }
  184. }
  185. },
  186. computed: {
  187. startDate() {
  188. return this.getDate('start');
  189. },
  190. endDate() {
  191. return this.getDate('end');
  192. }
  193. },
  194. onLoad() {
  195. const userInfo = uni.getStorageSync('userInfo');
  196. const orgInfo = uni.getStorageSync('orgInfo');
  197. this.form.userName = userInfo.nickName
  198. this.form.userNo = userInfo.userName
  199. this.form.orgNo = orgInfo.organizationCode
  200. this.form.orgName = orgInfo.organizationName
  201. //是否打卡
  202. this.isClockingIn()
  203. },
  204. created() {
  205. this.getList()
  206. },
  207. methods: {
  208. bindStartDateChange: function(e) {
  209. this.form.vacateStartTime = e.detail.value
  210. },
  211. bindEndDateChange: function(e) {
  212. this.form.vacateEndTime = e.detail.value
  213. },
  214. getDate(type) {
  215. const date = new Date();
  216. let year = date.getFullYear();
  217. let month = date.getMonth() + 1;
  218. let day = date.getDate();
  219. if (type === 'start') {
  220. year = year - 60;
  221. } else if (type === 'end') {
  222. year = year + 2;
  223. }
  224. month = month > 9 ? month : '0' + month;
  225. day = day > 9 ? day : '0' + day;
  226. return `${year}-${month}-${day}`;
  227. },
  228. async getQueList() {
  229. const {
  230. data: res
  231. } = await this.$httpRequest({
  232. url: '/api/yq/list?queGroupId=' + 2,
  233. method: 'get',
  234. })
  235. if (res.code == 200) {
  236. this.queDbList = res.data
  237. this.queDbList.forEach(q => {
  238. this.form.ques.push(q.id)
  239. })
  240. } else {
  241. }
  242. },
  243. async save() {
  244. const {
  245. data: res
  246. } = await this.$httpRequest({
  247. method: 'POST',
  248. url: '/api/ci/clocking/in',
  249. data: this.form
  250. })
  251. if (res.code == 200) {
  252. uni.showToast({
  253. title: res.msg,
  254. icon: 'success'
  255. })
  256. setTimeout(() => {
  257. location.reload()
  258. }, 1000)
  259. } else {
  260. uni.showToast({
  261. title: res.msg,
  262. icon: "none"
  263. })
  264. }
  265. },
  266. async isClockingIn() {
  267. const {
  268. data: res
  269. } = await this.$httpRequest({
  270. method: 'POST',
  271. url: '/api/ci/clocking/info',
  272. data: this.form
  273. })
  274. if (res.code == 200) {
  275. if (undefined !== res.data) {
  276. console.log("not null")
  277. this.isOffDuty = true
  278. this.form.clockInType = 5
  279. }
  280. } else {
  281. }
  282. },
  283. getList() {
  284. this.getQueList();
  285. },
  286. submit() {
  287. this.disabled = true
  288. console.log(this.form.vacateStartTime)
  289. if (this.form.vacateStartTime > this.form.vacateEndTime) {
  290. uni.showToast({
  291. title: '结束时间小于开始时间',
  292. icon: 'none'
  293. })
  294. this.disabled = false
  295. return;
  296. }
  297. this.save()
  298. setTimeout(() => {
  299. this.disabled = false
  300. }, 2000)
  301. }
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. .wrapper {
  307. display: flex;
  308. flex-direction: column;
  309. min-height: 100%;
  310. }
  311. .header {
  312. flex: 0;
  313. margin-top: 20px;
  314. }
  315. .main {
  316. flex: 1;
  317. margin: 20px 0;
  318. }
  319. .footer {
  320. flex: 0;
  321. }
  322. .uni-fixed-bottom {
  323. width: 100%;
  324. bottom: 0upx;
  325. padding: 0upx;
  326. position: fixed;
  327. background: #FFFFFF;
  328. transform: translateZ(0);
  329. bottom: env(safe-area-inset-bottom);
  330. bottom: constant(safe-area-inset-bottom);
  331. }
  332. .u-page {
  333. &__style {
  334. font-size: 16px;
  335. color: rgb(96, 98, 102);
  336. margin-bottom: 20rpx;
  337. font-weight: bold;
  338. }
  339. &__title {
  340. font-size: 16px;
  341. color: rgb(96, 98, 102);
  342. margin-bottom: 20rpx;
  343. }
  344. }
  345. </style>