create.vue 14 KB

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