JPattributeEditor.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <div class="JPattributeEditor">
  3. <van-nav-bar class="navBar" title="金牌店档案编辑" left-arrow @click-left="onClickLeft" />
  4. <div class="content" v-if="detail">
  5. <van-form ref="tabstoreVal">
  6. <van-field
  7. class="sendCode"
  8. v-model="detail.ownerMobile"
  9. label="主经营者电话"
  10. placeholder="请输入主经营者电话"
  11. type="tel">
  12. <template #button>
  13. <van-button
  14. size="small"
  15. style="color: white; background: rgb(0, 87, 186); border-radius: 6px"
  16. @click="sendCode(detail.ownerMobile)"
  17. :disabled="time != null"
  18. >发送验证码<span v-if="time">({{ timeNum }})</span>
  19. </van-button>
  20. </template>
  21. </van-field>
  22. <van-field
  23. v-model="verificationVal"
  24. label="主经营者收到的验证码"
  25. placeholder="请输入验证码"
  26. type="number"
  27. @blur="verification(verificationVal)" />
  28. <van-field v-model="detail.ownerName" label="主经营者姓名" />
  29. <van-field
  30. v-model="detail.ownerBirthday"
  31. label="主经营者出生日期"
  32. placeholder="请输入主经营者出生日期"
  33. @click="getNyr('ownerBirthday')" />
  34. <van-field autosize type="textarea" label="主营/擅长经营品类">
  35. <template #input>
  36. <van-checkbox-group v-model="detail.mainProductCategorys" direction="horizontal">
  37. <van-checkbox
  38. v-for="(item, index) in mainProductCategorys"
  39. :name="item.dictValue"
  40. shape="square"
  41. :key="index">
  42. {{ item.dictValue }}
  43. </van-checkbox>
  44. </van-checkbox-group>
  45. </template>
  46. </van-field>
  47. <van-field
  48. v-model="detail.totalSalesAmount"
  49. autosize
  50. type="textarea"
  51. label="门店24年总销量(以进货额计)" />
  52. <van-field v-model="detail.performanceRatio" type="number" label="立邦业绩占比(%)" />
  53. <van-field v-model="detail.mainBrand" autosize type="textarea" label="主营T0P3品牌" />
  54. <van-field v-model="detail.emergencyContact" label="紧急联系人姓名" />
  55. <van-field
  56. v-model="detail.emergencyContactBirthday"
  57. label="紧急联系人出生日期"
  58. @click="getNyr('emergencyContactBirthday')" />
  59. <van-field v-model="detail.emergencyContactMobile" type="number" label="紧急联系人电话" />
  60. <van-field label="紧急联系人身份">
  61. <template #input>
  62. <van-radio-group v-model="detail.emergencyContactRelation" direction="horizontal">
  63. <van-radio
  64. v-for="(item, index) in emergencyContactRelation"
  65. :name="item.dictValue"
  66. :key="index">
  67. {{ item.dictValue }}
  68. </van-radio>
  69. </van-radio-group>
  70. </template>
  71. </van-field>
  72. </van-form>
  73. </div>
  74. <div class="footer-btn">
  75. <van-button
  76. style="color: white; background: rgb(0, 87, 186); border-radius: 6px; width: 90%"
  77. @click="confirmShare">
  78. 保 存
  79. </van-button>
  80. </div>
  81. <!-- 时间选择 -->
  82. <van-popup v-model="datetimeShowPicker" position="bottom">
  83. <van-datetime-picker
  84. type="date"
  85. title="选择年月日"
  86. :min-date="new Date(1945, 0, 1)"
  87. :max-date="new Date()"
  88. @confirm="datetimeOnConfirm"
  89. @cancel="datetimeShowPicker = false" />
  90. </van-popup>
  91. </div>
  92. </template>
  93. <script>
  94. import { sendAndCheckVerCode, getDictOption } from '@/api/index';
  95. import { getStoreArchives, updateArchives } from '@/api/storeManagement';
  96. export default {
  97. name: 'JPattributeEditor',
  98. data() {
  99. return {
  100. detail: null,
  101. time: null, //计时
  102. timeNum: 30,
  103. verificationVal: '',
  104. datetimeShowPicker: false,
  105. activatNyrItem: '',
  106. checkboxGroup: [],
  107. mainProductCategorys: [],
  108. emergencyContactRelation: [],
  109. verificationPassedPhoneNum: '', //验证通过手机号
  110. };
  111. },
  112. activated() {
  113. if (this.time) clearInterval(this.time);
  114. this.time = null; //计时
  115. this.timeNum = 30;
  116. this.toastLoading(0, '加载中...', true);
  117. getDictOption({}, 'archives_main_product_categorys').then((res) => {
  118. let mainProductCategorys = [];
  119. let emergencyContactRelation = [];
  120. res.data.forEach((val) => {
  121. if (val.remark == 'mainProductCategorys') {
  122. mainProductCategorys.push(val);
  123. } else {
  124. emergencyContactRelation.push(val);
  125. }
  126. });
  127. this.mainProductCategorys = mainProductCategorys;
  128. this.emergencyContactRelation = emergencyContactRelation;
  129. this.getDetaild();
  130. });
  131. },
  132. methods: {
  133. getDetaild() {
  134. getStoreArchives({ storeCode: this.$route.query.storeCode }).then((res) => {
  135. this.toastLoading().clear();
  136. if (res.code == 200) {
  137. // let copyData = JSON.parse(JSON.stringify(res.data));
  138. res.data.mainProductCategorys = res.data.mainProductCategorys
  139. ? res.data.mainProductCategorys.split(',')
  140. : [];
  141. this.detail = res.data;
  142. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  143. }
  144. });
  145. },
  146. // 发送验证码
  147. sendCode(val) {
  148. if (!/^1[3456789]\d{9}$/.test(val) || val == '') {
  149. this.$toast('格式错误');
  150. return;
  151. }
  152. if (this.time) return;
  153. clearInterval(this.time);
  154. this.timeNum = 30;
  155. this.sendCodeFun(
  156. {
  157. type: '1', //String 调用类型:1:发送验证码 2:校验验证码
  158. phone: val, //String 手机号
  159. verification: '', //String 手机号验证码
  160. },
  161. () => {
  162. this.time = setInterval(() => {
  163. this.timeNum--;
  164. if (this.timeNum <= 0) {
  165. clearInterval(this.time);
  166. this.time = null;
  167. }
  168. }, 1000);
  169. this.$toast('发送成功');
  170. }
  171. );
  172. },
  173. sendCodeFun(params, callback) {
  174. sendAndCheckVerCode(params).then((res) => {
  175. if (res.code == 200) {
  176. callback && callback(res);
  177. }
  178. });
  179. },
  180. verification(val) {
  181. // 验证码
  182. if (val == '') {
  183. return;
  184. }
  185. // 手机号
  186. if (this.detail.ownerMobile == '') {
  187. return;
  188. }
  189. this.sendCodeFun(
  190. {
  191. type: '2', //String 调用类型:1:发送验证码 2:校验验证码
  192. phone: this.detail.ownerMobile, //String 手机号
  193. verification: val, //String 手机号验证码
  194. },
  195. (res) => {
  196. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  197. this.$toast(res.data ? '验证成功' : '验证码错误');
  198. }
  199. );
  200. },
  201. getNyr(val) {
  202. this.activatNyrItem = val;
  203. this.datetimeShowPicker = true;
  204. },
  205. datetimeOnConfirm(time) {
  206. this.$set(this.detail, this.activatNyrItem, this.parseTime(time, '{y}-{m}-{d}'));
  207. // this.detail.ownerBirthday = this.parseTime(time, '{y}-{m}-{d}');
  208. this.datetimeShowPicker = false;
  209. },
  210. // 保存
  211. confirmShare() {
  212. if (this.detail.ownerMobile != this.verificationPassedPhoneNum) {
  213. this.$toast('请验证手机号');
  214. return;
  215. }
  216. this.toastLoading(0, '加载中...', true);
  217. let params = JSON.parse(JSON.stringify(this.detail));
  218. params.mainProductCategorys = params.mainProductCategorys.join(',');
  219. updateArchives(params).then((res) => {
  220. this.toastLoading().clear();
  221. if (res.code == 200) {
  222. this.$toast(res.msg);
  223. this.$router.go(-1);
  224. } else {
  225. this.$toast(res.msg);
  226. }
  227. });
  228. },
  229. emergencyContactBlur(val) {
  230. if (!/^1[3456789]\d{9}$/.test(val)) {
  231. this.$toast('格式错误');
  232. }
  233. },
  234. onClickLeft() {
  235. this.$router.go(-1);
  236. },
  237. },
  238. };
  239. </script>
  240. <style lang="scss">
  241. .JPattributeEditor {
  242. width: 100%;
  243. height: 100%;
  244. display: flex;
  245. flex-direction: column;
  246. justify-content: space-between;
  247. overflow: hidden;
  248. .content {
  249. flex: 1;
  250. overflow-y: auto;
  251. background: #fff;
  252. padding: 10px 15px;
  253. margin-top: 10px;
  254. background: #fff;
  255. .van-cell {
  256. padding: 10px 0;
  257. border-bottom: 1px solid #ccc;
  258. }
  259. .van-field__label {
  260. width: 9em;
  261. }
  262. .sendCode {
  263. border: none !important;
  264. input {
  265. border: 1px solid #f1f1f1;
  266. height: 35px;
  267. }
  268. }
  269. .van-checkbox--horizontal {
  270. margin-bottom: 10px;
  271. width: 100%;
  272. }
  273. .van-radio--horizontal {
  274. margin-bottom: 10px;
  275. }
  276. }
  277. .footer-btn {
  278. display: flex;
  279. justify-content: space-around;
  280. padding: 10px 0;
  281. }
  282. }
  283. </style>