create.vue 12 KB

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