JPattributeEditor.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  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
  60. v-model="detail.emergencyContactMobile"
  61. type="number"
  62. @blur="emergencyContactBlur(detail.emergencyContactMobile)"
  63. label="紧急联系人电话" />
  64. <van-field label="紧急联系人身份">
  65. <template #input>
  66. <van-radio-group v-model="detail.emergencyContactRelation" direction="horizontal">
  67. <van-radio
  68. v-for="(item, index) in emergencyContactRelation"
  69. :name="item.dictValue"
  70. :key="index">
  71. {{ item.dictValue }}
  72. </van-radio>
  73. </van-radio-group>
  74. </template>
  75. </van-field>
  76. </van-form>
  77. </div>
  78. <div class="footer-btn">
  79. <van-button
  80. style="color: white; background: rgb(0, 87, 186); border-radius: 6px; width: 90%"
  81. @click="confirmShare">
  82. 保 存
  83. </van-button>
  84. </div>
  85. <!-- 时间选择 -->
  86. <van-popup v-model="datetimeShowPicker" position="bottom">
  87. <van-datetime-picker
  88. type="date"
  89. title="选择年月日"
  90. :min-date="new Date(1945, 0, 1)"
  91. :max-date="new Date()"
  92. @confirm="datetimeOnConfirm"
  93. @cancel="datetimeShowPicker = false" />
  94. </van-popup>
  95. </div>
  96. </template>
  97. <script>
  98. import { sendAndCheckVerCode, getDictOption } from '@/api/index';
  99. import { getStoreArchives, updateArchives } from '@/api/storeManagement';
  100. export default {
  101. name: 'JPattributeEditor',
  102. data() {
  103. return {
  104. detail: null,
  105. time: null, //计时
  106. timeNum: 30,
  107. verificationVal: '',
  108. datetimeShowPicker: false,
  109. activatNyrItem: '',
  110. checkboxGroup: [],
  111. mainProductCategorys: [],
  112. emergencyContactRelation: [],
  113. verificationPassedPhoneNum: '', //验证通过手机号
  114. };
  115. },
  116. activated() {
  117. if (this.time) clearInterval(this.time);
  118. this.time = null; //计时
  119. this.timeNum = 30;
  120. this.toastLoading(0, '加载中...', true);
  121. getDictOption({}, 'archives_main_product_categorys').then((res) => {
  122. let mainProductCategorys = [];
  123. let emergencyContactRelation = [];
  124. res.data.forEach((val) => {
  125. if (val.remark == 'mainProductCategorys') {
  126. mainProductCategorys.push(val);
  127. } else {
  128. emergencyContactRelation.push(val);
  129. }
  130. });
  131. this.mainProductCategorys = mainProductCategorys;
  132. this.emergencyContactRelation = emergencyContactRelation;
  133. this.getDetaild();
  134. });
  135. },
  136. methods: {
  137. getDetaild() {
  138. getStoreArchives({ storeCode: this.$route.query.storeCode }).then((res) => {
  139. this.toastLoading().clear();
  140. if (res.code == 200) {
  141. // let copyData = JSON.parse(JSON.stringify(res.data));
  142. res.data.mainProductCategorys = res.data.mainProductCategorys.split(',');
  143. this.detail = res.data;
  144. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  145. }
  146. });
  147. },
  148. // 发送验证码
  149. sendCode(val) {
  150. if (!/^1[3456789]\d{9}$/.test(val) || val == '') {
  151. this.$toast('格式错误');
  152. return;
  153. }
  154. if (this.time) return;
  155. clearInterval(this.time);
  156. this.timeNum = 30;
  157. this.sendCodeFun(
  158. {
  159. type: '1', //String 调用类型:1:发送验证码 2:校验验证码
  160. phone: val, //String 手机号
  161. verification: '', //String 手机号验证码
  162. },
  163. () => {
  164. this.time = setInterval(() => {
  165. this.timeNum--;
  166. if (this.timeNum <= 0) {
  167. clearInterval(this.time);
  168. this.time = null;
  169. }
  170. }, 1000);
  171. this.$toast('发送成功');
  172. }
  173. );
  174. },
  175. sendCodeFun(params, callback) {
  176. sendAndCheckVerCode(params).then((res) => {
  177. if (res.code == 200) {
  178. callback && callback(res);
  179. }
  180. });
  181. },
  182. verification(val) {
  183. // 验证码
  184. if (val == '') {
  185. return;
  186. }
  187. // 手机号
  188. if (this.detail.ownerMobile == '') {
  189. return;
  190. }
  191. this.sendCodeFun(
  192. {
  193. type: '2', //String 调用类型:1:发送验证码 2:校验验证码
  194. phone: this.detail.ownerMobile, //String 手机号
  195. verification: val, //String 手机号验证码
  196. },
  197. (res) => {
  198. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  199. this.$toast(res.data ? '验证成功' : '验证码错误');
  200. }
  201. );
  202. },
  203. getNyr(val) {
  204. this.activatNyrItem = val;
  205. this.datetimeShowPicker = true;
  206. },
  207. datetimeOnConfirm(time) {
  208. this.$set(this.detail, this.activatNyrItem, this.parseTime(time, '{y}-{m}-{d}'));
  209. // this.detail.ownerBirthday = this.parseTime(time, '{y}-{m}-{d}');
  210. this.datetimeShowPicker = false;
  211. },
  212. // 保存
  213. confirmShare() {
  214. if (this.detail.ownerMobile != this.verificationPassedPhoneNum) {
  215. this.$toast('请验证手机号');
  216. return;
  217. }
  218. if (
  219. !/^1[3456789]\d{9}$/.test(this.detail.emergencyContactMobile) ||
  220. this.detail.emergencyContactMobile == ''
  221. ) {
  222. this.$toast('紧急联系人电话格式错误');
  223. return;
  224. }
  225. this.toastLoading(0, '加载中...', true);
  226. let params = JSON.parse(JSON.stringify(this.detail));
  227. params.mainProductCategorys = params.mainProductCategorys.join(',');
  228. updateArchives(params).then((res) => {
  229. this.toastLoading().clear();
  230. if (res.code == 200) {
  231. this.$toast(res.msg);
  232. this.$router.go(-1);
  233. } else {
  234. this.$toast(res.msg);
  235. }
  236. });
  237. },
  238. emergencyContactBlur(val) {
  239. if (!/^1[3456789]\d{9}$/.test(val) || val == '') {
  240. this.$toast('格式错误');
  241. }
  242. },
  243. onClickLeft() {
  244. this.$router.go(-1);
  245. },
  246. },
  247. };
  248. </script>
  249. <style lang="scss">
  250. .JPattributeEditor {
  251. width: 100%;
  252. height: 100%;
  253. display: flex;
  254. flex-direction: column;
  255. justify-content: space-between;
  256. overflow: hidden;
  257. .content {
  258. flex: 1;
  259. overflow-y: auto;
  260. background: #fff;
  261. padding: 10px 15px;
  262. margin-top: 10px;
  263. background: #fff;
  264. .van-cell {
  265. padding: 10px 0;
  266. border-bottom: 1px solid #ccc;
  267. }
  268. .van-field__label {
  269. width: 9em;
  270. }
  271. .sendCode {
  272. border: none !important;
  273. input {
  274. border: 1px solid #f1f1f1;
  275. height: 35px;
  276. }
  277. }
  278. .van-checkbox--horizontal {
  279. margin-bottom: 10px;
  280. width: 100%;
  281. }
  282. .van-radio--horizontal {
  283. margin-bottom: 10px;
  284. }
  285. }
  286. .footer-btn {
  287. display: flex;
  288. justify-content: space-around;
  289. padding: 10px 0;
  290. }
  291. }
  292. </style>