sign.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. <template>
  2. <view>
  3. <uni-section title="纵向排列" type="line"></uni-section>
  4. <view class="" style="padding-top: 5upx;padding-bottom: 10upx;">
  5. <view class="" style="width: 60%;">
  6. <view class="tr">
  7. <view class="td-left">
  8. 员工:
  9. </view>
  10. <view class="td-right">
  11. <!-- <select class="option" name="weixinName1" id="" v-model="weixinId1" @change='changeWeixin1'>
  12. <option value="0">--全部--</option>
  13. <option :value="weixin.id" v-for='weixin in weixinList' :key="weixin.id">{{ weixin.workName }} </option>
  14. </select> -->
  15. <picker class="option2" @change="changeWeixin" :value="index" :range="weixinList">
  16. <view class="wenzi">{{weixinList[index]}}</view>
  17. </picker>
  18. </view>
  19. </view>
  20. <view class="tr">
  21. <view class="td-left">
  22. 厕所:
  23. </view>
  24. <view class="td-right">
  25. <picker class="option2" @change="changeEquipment" :value="index2" :range="equipmentList">
  26. <view class="uni-input">{{equipmentList[index2]}}</view>
  27. </picker>
  28. </view>
  29. </view>
  30. <view class="tr">
  31. <view class="td-left">
  32. 开始时间:
  33. </view>
  34. <view class="td-right">
  35. <picker class="option2" mode="date" :value="date1" :start="startDate" :end="endDate" @change="bindDateChange1">
  36. <view class="uni-input">{{date1}}</view>
  37. </picker>
  38. </view>
  39. </view>
  40. <view class="tr">
  41. <view class="td-left">
  42. 结束时间:
  43. </view>
  44. <view class="td-right">
  45. <picker class="option2" mode="date" :value="date2" :start="startDate" :end="endDate" @change="bindDateChange2">
  46. <view class="uni-input">{{date2}}</view>
  47. </picker>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. <view class="example-body">
  53. <uni-steps :options="list2" active-color="#007AFF" :active="active" direction="column" />
  54. </view>
  55. <!-- <view class="word-btn" hover-class="word-btn--hover" :hover-start-time="20" :hover-stay-time="70" @click="change"><text class="word-btn-white">改变状态</text></view> -->
  56. </view>
  57. </template>
  58. <script>
  59. import uniSteps from '../../resource/uni-steps/uni-steps.vue'
  60. import uniSection from '../../resource/uni-section/uni-section.vue'
  61. export default {
  62. components: {
  63. uniSection,
  64. uniSteps
  65. },
  66. data() {
  67. const currentDate = this.getDate({
  68. format: true
  69. })
  70. return {
  71. index: 0,
  72. index2: 0,
  73. date1: currentDate,
  74. date2: currentDate,
  75. weixins: [],
  76. weixinList: [],
  77. equipments: [],
  78. equipmentList: [],
  79. weixinId1: null,
  80. equipmentId1: null,
  81. active: 0,
  82. list2: [],
  83. level: 3
  84. }
  85. },
  86. computed: {
  87. startDate() {
  88. return this.getDate('start');
  89. },
  90. endDate() {
  91. return this.getDate('end');
  92. }
  93. },
  94. onShow() {
  95. this.globalUser = uni.getStorageSync("globalUser");
  96. var token = uni.getStorageSync("token");
  97. this.level = uni.getStorageSync("level");
  98. if (token.length > 1) {
  99. this.worker();
  100. this.equipmentes();
  101. if (token.length > 2) {
  102. this.change();
  103. }
  104. } else {
  105. uni.reLaunch({
  106. url: '../Login/Login',
  107. });
  108. }
  109. },
  110. methods: {
  111. change() {
  112. var that = this;
  113. var serverUrl = that.serverurl;
  114. var token = uni.getStorageSync("token");
  115. if (that.index == 0) {
  116. var work = 0;
  117. } else {
  118. var weixins = that.weixins;
  119. var index = that.index;
  120. for (var j = 0; j < weixins.length; j++) {
  121. if (j == index) {
  122. var work = weixins[j].workName;
  123. }
  124. }
  125. }
  126. if (that.index2 == 0) {
  127. var clientId = 0;
  128. } else {
  129. var clientId = that.equipments[that.index2].clientId;
  130. }
  131. var newparm = uni.getStorageSync("newparm");
  132. var openId = newparm.openId;
  133. var startDate = that.date1 + " 00:00:00";
  134. var endDate = that.date2 + " 23:59:59";
  135. var a = new Date(startDate);
  136. var b = new Date(endDate);
  137. if (a > b) {
  138. var temp = startDate;
  139. endDate = startDate;
  140. startDate = temp;
  141. }
  142. uni.request({
  143. url: serverUrl + "/TSign/getSignList",
  144. method: "GET",
  145. header: {
  146. 'token': token
  147. },
  148. data: {
  149. "openId": openId,
  150. "workName": work,
  151. "clientId": clientId,
  152. "startDate": startDate,
  153. "endDate": endDate
  154. },
  155. success: (Result) => {
  156. var res = Result;
  157. if (res.data.code == true) {
  158. this.list2 = res.data.data;
  159. } else {
  160. uni.showModal({
  161. title: '提示',
  162. content: res.data.message,
  163. });
  164. this.list2 = [];
  165. }
  166. }
  167. });
  168. },
  169. equipmentes() {
  170. var equipments = uni.getStorageSync("listName");
  171. this.equipments = equipments;
  172. var equipmentList = [];
  173. if (this.level < 2) {
  174. equipmentList.push("全部");
  175. }
  176. for (var i = 0; i < equipments.length; i++) {
  177. equipmentList.push(equipments[i].name);
  178. }
  179. this.equipmentList = equipmentList;
  180. },
  181. changeWeixin: function(e) {
  182. this.index = e.target.value;
  183. this.change();
  184. },
  185. changeEquipment: function(e) {
  186. this.index2 = e.target.value;
  187. this.change();
  188. },
  189. worker() {
  190. var newparm = uni.getStorageSync("newparm");
  191. if (newparm.toString().length > 1) {
  192. if (newparm.openId.length > 1) {
  193. var that = this;
  194. var serverUrl = that.serverurl;
  195. var token = uni.getStorageSync("token");
  196. var openId = newparm.openId;
  197. uni.request({
  198. url: serverUrl + "/TWeixin/getWeixinList?openId=" + openId,
  199. method: "GET",
  200. header: {
  201. 'token': token
  202. },
  203. success: (Result) => {
  204. var res = Result;
  205. if (res.data.code == true) {
  206. var list = res.data.data;
  207. this.weixins = list;
  208. var weixinList = [];
  209. if (this.level < 2) {
  210. weixinList.push("全部");
  211. }
  212. for (var i = 0; i < list.length; i++) {
  213. weixinList.push(list[i].workName);
  214. }
  215. this.weixinList = weixinList;
  216. } else {
  217. uni.showModal({
  218. title: '提示',
  219. content: res.data.message,
  220. });
  221. }
  222. }
  223. });
  224. }
  225. }
  226. },
  227. bindDateChange1: function(e) {
  228. this.date1 = e.target.value;
  229. this.change();
  230. },
  231. bindDateChange2: function(e) {
  232. this.date2 = e.target.value;
  233. this.change();
  234. },
  235. getDate(type) {
  236. const date = new Date();
  237. let year = date.getFullYear();
  238. let month = date.getMonth() + 1;
  239. let day = date.getDate();
  240. if (type === 'start') {
  241. year = year - 60;
  242. } else if (type === 'end') {
  243. year = year + 2;
  244. }
  245. month = month > 9 ? month : '0' + month;;
  246. day = day > 9 ? day : '0' + day;
  247. return `${year}-${month}-${day}`;
  248. }
  249. }
  250. }
  251. </script>
  252. <style>
  253. /* 头条小程序组件内不能引入字体 */
  254. /* #ifdef MP-TOUTIAO */
  255. @font-face {
  256. font-family: uniicons;
  257. font-weight: normal;
  258. font-style: normal;
  259. src: url('~@/static/uni.ttf') format('truetype');
  260. }
  261. /* #endif */
  262. /* #ifndef APP-NVUE */
  263. page {
  264. display: flex;
  265. flex-direction: column;
  266. box-sizing: border-box;
  267. background-color: #efeff4;
  268. min-height: 100%;
  269. height: auto;
  270. }
  271. view {
  272. font-size: 28rpx;
  273. line-height: inherit;
  274. }
  275. .example {
  276. padding: 0 30rpx 30rpx;
  277. }
  278. .example-info {
  279. padding: 30rpx;
  280. color: #3b4144;
  281. background: #ffffff;
  282. }
  283. .example-body {
  284. flex-direction: row;
  285. flex-wrap: wrap;
  286. justify-content: center;
  287. padding: 0;
  288. font-size: 14rpx;
  289. background-color: #ffffff;
  290. }
  291. /* #endif */
  292. .example {
  293. padding: 0 30rpx;
  294. }
  295. .example-info {
  296. /* #ifndef APP-NVUE */
  297. display: block;
  298. /* #endif */
  299. padding: 30rpx;
  300. color: #3b4144;
  301. background-color: #ffffff;
  302. font-size: 30rpx;
  303. }
  304. .example-info-text {
  305. font-size: 28rpx;
  306. line-height: 36rpx;
  307. }
  308. .example-body {
  309. flex-direction: column;
  310. padding: 30rpx;
  311. background-color: #ffffff;
  312. }
  313. .word-btn-white {
  314. font-size: 18px;
  315. color: #FFFFFF;
  316. }
  317. .word-btn {
  318. /* #ifndef APP-NVUE */
  319. display: flex;
  320. /* #endif */
  321. flex-direction: row;
  322. align-items: center;
  323. justify-content: center;
  324. border-radius: 6px;
  325. height: 48px;
  326. margin: 15px;
  327. background-color: #007AFF;
  328. }
  329. .word-btn--hover {
  330. background-color: #4ca2ff;
  331. }
  332. .status-btn {
  333. /* #ifndef APP-NVUE */
  334. display: flex;
  335. /* #endif */
  336. flex-direction: row;
  337. align-items: center;
  338. justify-content: center;
  339. height: 92rpx;
  340. margin: 30rpx;
  341. background-color: #007AFF;
  342. }
  343. .example-body {
  344. /* #ifndef APP-NVUE */
  345. display: block;
  346. /* #endif */
  347. padding: 15px;
  348. flex-direction: row;
  349. }
  350. .tr {
  351. padding-top: 20upx;
  352. display: flex;
  353. flex-direction: row;
  354. justify-content: flex-start;
  355. font-size: 26upx;
  356. font-family: "PingFang-SC-Bold";
  357. }
  358. .td-left {
  359. font-family: "PingFang-SC-Bold";
  360. margin: auto;
  361. font-size: 26upx;
  362. width: 30%;
  363. text-align: right;
  364. }
  365. .td-right {
  366. font-family: "PingFang-SC-Bold";
  367. /* font-weight: bold; */
  368. margin: auto;
  369. /* font-size: 26upx; */
  370. width: 60%;
  371. text-align: left;
  372. }
  373. .option {
  374. height: 40upx;
  375. border: 1px solid blue;
  376. }
  377. .option2 {
  378. border: 1px solid blue;
  379. }
  380. .wenzi {
  381. padding: 15rpx 25rpx;
  382. line-height: 50rpx;
  383. font-size: 28rpx;
  384. background: #FFF;
  385. -webkit-box-flex: 1;
  386. -webkit-flex: 1;
  387. flex: 1;
  388. }
  389. </style>