add.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. <template>
  2. <div class="form-submit">
  3. <Card :bordered="false" dis-hover class="ivu-mt">
  4. <Form :model="formData" :label-width="150">
  5. <FormItem label="规则名称" required>
  6. <Input v-model="formData.groupname" v-width="320"></Input>
  7. </FormItem>
  8. <FormItem label="打卡员工" required>
  9. <template v-for="item in checkedStaff">
  10. <Tag>{{item.name}}</Tag>
  11. </template>
  12. <Button type="primary" @click="chooseSatff">选择员工</Button>
  13. </FormItem>
  14. <FormItem label="打卡经度">
  15. <Input v-model="formData.loc_infos[0].lng" v-width="320"></Input>
  16. <span> (实际经度的1000000倍)</span>
  17. </FormItem>
  18. <FormItem label="打卡纬度">
  19. <Input v-model="formData.loc_infos[0].lat" v-width="320"></Input>
  20. <span> (实际纬度的1000000倍)</span>
  21. </FormItem>
  22. <FormItem label="打卡地名">
  23. <Input v-model="formData.loc_infos[0].loc_title" v-width="320"></Input>
  24. <span> (实际纬度的1000000倍)</span>
  25. </FormItem>
  26. <FormItem label="打卡详细地址">
  27. <Input v-model="formData.loc_infos[0].loc_detail" v-width="320"></Input>
  28. <span> (实际纬度的1000000倍)</span>
  29. </FormItem>
  30. <FormItem label="WiFi名称">
  31. <Input v-model="formData.wifimac_infos[0].wifiname" v-width="320"></Input>
  32. <span> </span>
  33. </FormItem>
  34. <FormItem label="无线路由器MAC地址">
  35. <Input v-model="formData.wifimac_infos[0].wifimac" v-width="320"></Input>
  36. <span> </span>
  37. </FormItem>
  38. <card v-for="(itemx,indexx) in formData.checkindate" style="width:1000px;">
  39. <div style="padding-bottom: 10px;">打卡时间
  40. <Button type="primary" style="margin-left: 20px;" @click="addNewDkTime()"
  41. v-if="indexx == 0">添加新打卡时间</Button>
  42. <Button type="primary" style="margin-left: 20px;" @click="delNewDkTime(indexx)"
  43. v-else>删除</Button>
  44. </div>
  45. <FormItem label="工作日" required>
  46. <TagSelect v-model="itemx.workdays" hide-check-all>
  47. <TagSelectOption :name="1">星期一</TagSelectOption>
  48. <TagSelectOption :name="2">星期二</TagSelectOption>
  49. <TagSelectOption :name="3">星期三</TagSelectOption>
  50. <TagSelectOption :name="4">星期四</TagSelectOption>
  51. <TagSelectOption :name="5">星期五</TagSelectOption>
  52. <TagSelectOption :name="6">星期六</TagSelectOption>
  53. <TagSelectOption :name="0">星期天</TagSelectOption>
  54. </TagSelect>
  55. </FormItem>
  56. <card v-for="(item,index) in itemx.checkintime" style="margin-bottom: 10px;">
  57. <FormItem label="时段id" required>
  58. <Input v-width="320" placeholder="大于0,小于99999,且唯一" v-model="item.time_id"></Input>
  59. <Button type="primary" style="margin-left: 20px;" @click="addNewDk(itemx)"
  60. v-if="index == 0">添加新上班时段</Button>
  61. <Button type="primary" style="margin-left: 20px;" @click="delNewDk(itemx,index)"
  62. v-else>删除</Button>
  63. </FormItem>
  64. <FormItem label="上班时间" required>
  65. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  66. v-model="item.work_sec" />
  67. </FormItem>
  68. <FormItem label="上班提醒时间" required>
  69. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  70. v-model="item.remind_work_sec" />
  71. </FormItem>
  72. <div style="padding: 0 0 10px 150px;">上班提醒时间不可晚于上班时间,且不可早于上班20分钟,只可以为准点、提前5分钟、提前10分钟、提前15分钟、提前20分钟</div>
  73. <FormItem label="上班最早时间" required>
  74. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  75. v-model="item.earliest_work_sec" />
  76. </FormItem>
  77. <FormItem label="上班最晚时间" required>
  78. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  79. v-model="item.latest_work_sec" />
  80. </FormItem>
  81. <FormItem label="下班时间" required>
  82. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  83. v-model="item.off_work_sec" />
  84. </FormItem>
  85. <FormItem label="下班提醒时间" required>
  86. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  87. v-model="item.remind_off_work_sec" />
  88. </FormItem>
  89. <div style="padding: 0 0 10px 150px;">下班提醒时间不可早于下班时间,且不可晚于下班60分钟,只可以为准点、下班后10分钟、下班后20分钟、下班后30分钟、下班后60分钟</div>
  90. <FormItem label="下班最早时间" required>
  91. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  92. v-model="item.earliest_off_work_sec" />
  93. </FormItem>
  94. <FormItem label="下班最晚时间" required>
  95. <TimePicker :steps="[1, 5]" placeholder="" v-width="320" format="HH:mm"
  96. v-model="item.latest_off_work_sec" />
  97. </FormItem>
  98. </card>
  99. </card>
  100. </Form>
  101. <div style="width: 500px; display: flex;justify-content: center;">
  102. <Button type="primary" class="submission" @click="save" :disabled="disabled"
  103. v-if="!formData.id">立即创建</Button>
  104. <Button type="primary" class="submission" @click="save" :disabled="disabled" v-else>立即修改</Button>
  105. <Button type="primary" @click="showDate()">测试数据</Button>
  106. </div>
  107. </Card>
  108. <Modal v-model="modals" title="员工列表" footerHide class="paymentFooter" scrollable width="900"
  109. @on-cancel="cancel">
  110. <staff-list ref="stafflist" :goodsType="1" v-if="modals" @getProductId="getProductId"
  111. :serviceCard="1"></staff-list>
  112. </Modal>
  113. </div>
  114. </template>
  115. <script>
  116. import {
  117. addCheckRule
  118. } from '@/api/check';
  119. import Setting from "@/setting";
  120. import staffList from '@/components/staffList'
  121. export default {
  122. name: "storeCouponCreate",
  123. components: {
  124. staffList
  125. },
  126. data() {
  127. return {
  128. checkedStaff: [],
  129. modals: false, //选择员工弹出
  130. value: '',
  131. id: '',
  132. work_sec: '',
  133. roterPre: Setting.roterPre,
  134. disabled: false,
  135. storesList: [],
  136. formData: {
  137. groupname: '',
  138. grouptype: 1, //规则类型: 1-固定时间上下班;2-按班次上下班;3-自由上下班
  139. type: 2, // 打卡方式 0-手机,2-考勤机,3-手机/考勤机
  140. loc_infos: [{
  141. lat: 30547030,
  142. lng: 104062890,
  143. loc_title: "腾讯成都大厦",
  144. loc_detail: "四川省成都市武侯区高新南区天府三街",
  145. distance: 300
  146. }],
  147. wifimac_infos: [{
  148. "wifiname": "Tencent-WiFi-1",
  149. "wifimac": "c0:7b:bc:37:f8:d3"
  150. }],
  151. range: {
  152. userid: [
  153. "qywx4633487382413312"
  154. ]
  155. }, //打卡人员
  156. checkindate: [{
  157. 'workdays': [],
  158. "checkintime": [{
  159. "time_id": '1',
  160. "work_sec": '', //上班时间(距0点秒数,整分钟)
  161. "off_work_sec": '', //下班时间
  162. "remind_work_sec": '', //上班提醒时间
  163. "remind_off_work_sec": '', //下班提醒时间
  164. "earliest_work_sec": '', //上班最早时间
  165. "latest_work_sec": '', //上班最晚时间
  166. "earliest_off_work_sec": '', //下班最早时间
  167. "latest_off_work_sec": '' // 下班最晚时间
  168. }],
  169. "flex_on_duty_time": 0,
  170. "flex_off_duty_time": 0
  171. }]
  172. },
  173. id: 0,
  174. product_name: '',
  175. product_id: 0,
  176. store_name: '',
  177. repertory: '',
  178. card_price: '',
  179. explain: '',
  180. unit_name: '',
  181. image: '',
  182. images: '',
  183. modals: false,
  184. }
  185. },
  186. created() {},
  187. methods: {
  188. // 测试数据
  189. showDate() {
  190. console.log('shuju', this.formData)
  191. },
  192. // 打开员工选择弹窗
  193. chooseSatff() {
  194. this.modals = true;
  195. },
  196. changeT(e) {
  197. // close()
  198. console.log(e, 'dddddddddddddd')
  199. },
  200. showTime(time) {
  201. let hh = '',
  202. mm = '';
  203. hh = Math.floor(time / 3600);
  204. hh = hh > 9 ? hh : ('0' + hh)
  205. mm = Math.floor((time % 3600) / 60);
  206. mm = mm > 9 ? mm : ('0' + mm)
  207. let str = hh + ':' + mm + ':' + '00'
  208. console.log('str:', str)
  209. return str
  210. },
  211. addNewDk(item) {
  212. item.checkintime.push({
  213. "time_id": '',
  214. "work_sec": '', //上班时间(距0点秒数,整分钟)
  215. "off_work_sec": '', //下班时间
  216. "remind_work_sec": '', //上班提醒时间
  217. "remind_off_work_sec": '', //下班提醒时间
  218. "earliest_work_sec": '', //上班最早时间
  219. "latest_work_sec": '', //上班最晚时间
  220. "earliest_off_work_sec": '', //下班最早时间
  221. "latest_off_work_sec": '' // 下班最晚时间
  222. })
  223. },
  224. addNewDkTime() {
  225. this.formData.checkindate.push({
  226. 'workdays': [],
  227. "checkintime": [{
  228. "time_id": '',
  229. "work_sec": '', //上班时间(距0点秒数,整分钟)
  230. "off_work_sec": '', //下班时间
  231. "remind_work_sec": '', //上班提醒时间
  232. "remind_off_work_sec": '', //下班提醒时间
  233. "earliest_work_sec": '', //上班最早时间
  234. "latest_work_sec": '', //上班最晚时间
  235. "earliest_off_work_sec": '', //下班最早时间
  236. "latest_off_work_sec": '' // 下班最晚时间
  237. }],
  238. "flex_on_duty_time": 0,
  239. "flex_off_duty_time": 0
  240. })
  241. },
  242. delNewDkTime(index) {
  243. this.formData.checkindate.splice(index, 1)
  244. },
  245. delNewDk(item,index) {
  246. item.splice(index, 1)
  247. },
  248. //
  249. onchangeTime(e) {
  250. console.log(e, 'xuanz');
  251. },
  252. // 商品id
  253. getProductId(row) {
  254. this.modals = false;
  255. console.log(row, '这个');
  256. this.checkedStaff = row
  257. let arr = []
  258. this.checkedStaff.forEach(item => {
  259. arr.push(item.userid)
  260. })
  261. this.formData.range.userid = arr
  262. },
  263. // 选择商品
  264. changeGoods() {
  265. this.modals = true;
  266. },
  267. downTab() {
  268. // if (!this.formData.store_name) {
  269. // return this.$Message.error("请输入服务卡名称");
  270. // }
  271. // if (!this.formData.card_price) {
  272. // return this.$Message.error("请输入售价");
  273. // }
  274. // if (!this.formData.repertory) {
  275. // return this.$Message.error("请输入库存");
  276. // }
  277. },
  278. getTime(str) {
  279. if(typeof(str) == 'string') {
  280. let arr = str.split(':')
  281. return arr[0]*60*60 + arr[1]*60
  282. }else {
  283. return str
  284. }
  285. },
  286. // 创建
  287. save() {
  288. let that = this
  289. this.downTab();
  290. console.log('这');
  291. let qdata = {}
  292. qdata = Object.assign(qdata,this.formData)
  293. try{
  294. // let qdata = JSON.parse(JSON.stringify(this.formData))
  295. let checkindate = []
  296. this.formData.checkindate.forEach(item => {
  297. // checkindate.push(item.)
  298. let mitem = []
  299. item.checkintime.forEach(itemt => {
  300. for(let key in itemt) {
  301. // let val = ''
  302. if(key != 'time_id') {
  303. itemt[key] = that.getTime(itemt[key])
  304. }else {
  305. itemt[key] = itemt[key]*1
  306. }
  307. }
  308. mitem.push(itemt)
  309. })
  310. item.checkintime = mitem
  311. checkindate.push(item)
  312. })
  313. qdata.checkindate = checkindate
  314. console.log(qdata,'this.formData')
  315. }catch(e){
  316. //TODO handle the exception
  317. console.log(e,'cuow')
  318. }
  319. addCheckRule({
  320. 'group': qdata
  321. })
  322. .then((res) => {
  323. this.disabled = true;
  324. this.$Message.success(res.msg);
  325. setTimeout(() => {
  326. this.$router.push({
  327. path: this.roterPre + "/store/checkRule/index",
  328. });
  329. }, 1000);
  330. })
  331. .catch((err) => {
  332. this.$Message.error(err.msg);
  333. this.disabled = false;
  334. });
  335. },
  336. cancel() {
  337. this.modals = false;
  338. },
  339. },
  340. };
  341. </script>
  342. <style scoped lang="stylus">
  343. .tips {
  344. display: inline-bolck;
  345. font-size: 12px;
  346. font-weight: 400;
  347. color: #999999;
  348. margin-top: 10px;
  349. }
  350. .imgPic {
  351. .info {
  352. width: 60%;
  353. margin-left: 10px;
  354. }
  355. .pictrue {
  356. height: 36px;
  357. margin: 7px 3px 0 3px;
  358. img {
  359. height: 100%;
  360. display: block;
  361. }
  362. }
  363. }
  364. .productType {
  365. width: 120px;
  366. height: 60px;
  367. background: #FFFFFF;
  368. border-radius: 3px;
  369. border: 1px solid #E7E7E7;
  370. float: left;
  371. text-align: center;
  372. padding-top: 8px;
  373. position: relative;
  374. cursor: pointer;
  375. line-height: 23px;
  376. margin-right: 12px;
  377. &.on {
  378. border-color: #1890FF;
  379. }
  380. .name {
  381. font-size: 14px;
  382. font-weight: 600;
  383. color: rgba(0, 0, 0, 0.85);
  384. &.on {
  385. color: #1890FF;
  386. }
  387. }
  388. .title {
  389. font-size: 12px;
  390. font-weight: 400;
  391. color: #999999;
  392. }
  393. .jiao {
  394. position: absolute;
  395. bottom: 0;
  396. right: 0;
  397. width: 0;
  398. height: 0;
  399. border-bottom: 26px solid #1890FF;
  400. border-left: 26px solid transparent;
  401. }
  402. .iconfont {
  403. position: absolute;
  404. bottom: -3px;
  405. right: 1px;
  406. color: #FFFFFF;
  407. font-size: 12px;
  408. }
  409. }
  410. .info {
  411. color: #888;
  412. font-size: 12px;
  413. }
  414. .ivu-input-wrapper {
  415. width: 320px;
  416. }
  417. .ivu-input-number {
  418. width: 160px;
  419. }
  420. .ivu-date-picker {
  421. width: 320px;
  422. }
  423. .ivu-icon-ios-camera-outline {
  424. width: 58px;
  425. height: 58px;
  426. border: 1px dotted rgba(0, 0, 0, 0.1);
  427. border-radius: 4px;
  428. background-color: rgba(0, 0, 0, 0.02);
  429. line-height: 58px;
  430. cursor: pointer;
  431. vertical-align: middle;
  432. }
  433. .upload-list {
  434. width: 58px;
  435. height: 58px;
  436. border: 1px dotted rgba(0, 0, 0, 0.1);
  437. border-radius: 4px;
  438. margin-right: 15px;
  439. display: inline-block;
  440. position: relative;
  441. cursor: pointer;
  442. vertical-align: middle;
  443. }
  444. .upload-list img {
  445. display: block;
  446. width: 100%;
  447. height: 100%;
  448. }
  449. .ivu-icon-ios-close-circle {
  450. position: absolute;
  451. top: 0;
  452. right: 0;
  453. transform: translate(50%, -50%);
  454. }
  455. .form-submit {
  456. /deep/.ivu-card {
  457. border-radius: 0;
  458. }
  459. margin-bottom: 79px;
  460. .fixed-card {
  461. position: fixed;
  462. right: 0;
  463. bottom: 0;
  464. left: 200px;
  465. z-index: 99;
  466. box-shadow: 0 -1px 2px rgb(240, 240, 240);
  467. /deep/ .ivu-card-body {
  468. padding: 15px 16px 14px;
  469. }
  470. .ivu-form-item {
  471. margin-bottom: 0;
  472. }
  473. /deep/ .ivu-form-item-content {
  474. margin-right: 124px;
  475. text-align: center;
  476. }
  477. .ivu-btn {
  478. height: 36px;
  479. padding: 0 20px;
  480. }
  481. }
  482. }
  483. /deep/.vxe-tree-cell {
  484. padding-left: 0 !important;
  485. }
  486. </style>