JPattributeEditor.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. <span v-else>发送验证码</span>
  20. </van-button>
  21. </template>
  22. </van-field>
  23. <van-field
  24. v-model="verificationVal"
  25. label="主经营者收到的验证码"
  26. placeholder="请输入验证码"
  27. type="number"
  28. @blur="verification(verificationVal)" />
  29. <van-field v-model="detail.ownerName" label="主经营者姓名" />
  30. <van-field
  31. v-model="detail.ownerBirthday"
  32. label="主经营者出生日期"
  33. placeholder="请输入主经营者出生日期"
  34. @click="getNyr('ownerBirthday', detail.ownerBirthday)" />
  35. <van-field autosize type="textarea" label="主营/擅长经营品类">
  36. <template #input>
  37. <van-checkbox-group v-model="detail.mainProductCategorys" direction="horizontal">
  38. <van-checkbox
  39. v-for="(item, index) in mainProductCategorys"
  40. :name="item.dictValue"
  41. shape="square"
  42. :key="index">
  43. {{ item.dictValue }}
  44. </van-checkbox>
  45. </van-checkbox-group>
  46. </template>
  47. </van-field>
  48. <van-field
  49. v-model="detail.totalSalesAmount"
  50. type="number"
  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', detail.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. v-model="currentDate"
  85. type="date"
  86. title="选择年月日"
  87. :min-date="minDate"
  88. :max-date="maxDate"
  89. @confirm="datetimeOnConfirm"
  90. @cancel="datetimeShowPicker = false" />
  91. </van-popup>
  92. </div>
  93. </template>
  94. <script>
  95. import { sendAndCheckVerCode, getDictOption } from '@/api/index';
  96. import { getStoreArchives, updateArchives } from '@/api/storeManagement';
  97. export default {
  98. name: 'JPattributeEditor',
  99. data() {
  100. return {
  101. detail: null,
  102. time: null, //计时
  103. timeNum: 60,
  104. verificationVal: '',
  105. datetimeShowPicker: false,
  106. activatNyrItem: '',
  107. checkboxGroup: [],
  108. mainProductCategorys: [],
  109. emergencyContactRelation: [],
  110. verificationPassedPhoneNum: '', //验证通过手机号
  111. minDate: new Date(1945, 0, 1),
  112. maxDate: new Date(),
  113. currentDate: new Date(1945, 0, 1),
  114. };
  115. },
  116. activated() {
  117. if (this.time) clearInterval(this.time);
  118. this.time = null; //计时
  119. this.timeNum = 60;
  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
  143. ? res.data.mainProductCategorys.split(',')
  144. : [];
  145. this.detail = res.data;
  146. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  147. }
  148. });
  149. },
  150. // 发送验证码
  151. sendCode(val) {
  152. if (!/^1[3456789]\d{9}$/.test(val) || val == '') {
  153. this.$toast('格式错误');
  154. return;
  155. }
  156. if (this.time) return;
  157. clearInterval(this.time);
  158. this.timeNum = 60;
  159. this.sendCodeFun(
  160. {
  161. type: '1', //String 调用类型:1:发送验证码 2:校验验证码
  162. phone: val, //String 手机号
  163. verification: '', //String 手机号验证码
  164. },
  165. () => {
  166. this.time = setInterval(() => {
  167. this.timeNum--;
  168. if (this.timeNum <= 0) {
  169. clearInterval(this.time);
  170. this.time = null;
  171. }
  172. }, 1000);
  173. this.$toast('发送成功');
  174. }
  175. );
  176. },
  177. sendCodeFun(params, callback) {
  178. sendAndCheckVerCode(params).then((res) => {
  179. if (res.code == 200) {
  180. callback && callback(res);
  181. }
  182. });
  183. },
  184. verification(val) {
  185. // 验证码
  186. if (val == '') {
  187. return;
  188. }
  189. // 手机号
  190. if (this.detail.ownerMobile == '') {
  191. return;
  192. }
  193. this.sendCodeFun(
  194. {
  195. type: '2', //String 调用类型:1:发送验证码 2:校验验证码
  196. phone: this.detail.ownerMobile, //String 手机号
  197. verification: val, //String 手机号验证码
  198. },
  199. (res) => {
  200. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  201. this.$toast(res.data ? '验证成功' : '验证码错误');
  202. }
  203. );
  204. },
  205. getNyr(val, date) {
  206. this.activatNyrItem = val;
  207. if (date && date != '') {
  208. let time = date.split('-');
  209. this.currentDate = new Date(time[0], Number(time[1]) - 1, time[2]);
  210. } else {
  211. this.currentDate = new Date(1945, 0, 1);
  212. }
  213. this.datetimeShowPicker = true;
  214. },
  215. datetimeOnConfirm(time) {
  216. this.$set(this.detail, this.activatNyrItem, this.parseTime(time, '{y}-{m}-{d}'));
  217. // this.detail.ownerBirthday = this.parseTime(time, '{y}-{m}-{d}');
  218. this.datetimeShowPicker = false;
  219. },
  220. // 保存
  221. confirmShare() {
  222. if (this.detail.ownerMobile != this.verificationPassedPhoneNum) {
  223. this.$toast('请验证手机号');
  224. return;
  225. }
  226. this.toastLoading(0, '加载中...', true);
  227. let params = JSON.parse(JSON.stringify(this.detail));
  228. params.mainProductCategorys = params.mainProductCategorys.join(',');
  229. updateArchives(params).then((res) => {
  230. this.toastLoading().clear();
  231. if (res.code == 200) {
  232. this.$toast(res.msg);
  233. this.$router.go(-1);
  234. } else {
  235. this.$toast(res.msg);
  236. }
  237. });
  238. },
  239. emergencyContactBlur(val) {
  240. if (!/^1[3456789]\d{9}$/.test(val)) {
  241. this.$toast('格式错误');
  242. }
  243. },
  244. onClickLeft() {
  245. this.$router.go(-1);
  246. },
  247. },
  248. };
  249. </script>
  250. <style lang="scss">
  251. .JPattributeEditor {
  252. width: 100%;
  253. height: 100%;
  254. display: flex;
  255. flex-direction: column;
  256. justify-content: space-between;
  257. overflow: hidden;
  258. .content {
  259. flex: 1;
  260. overflow-y: auto;
  261. background: #fff;
  262. padding: 10px 15px;
  263. margin-top: 10px;
  264. background: #fff;
  265. .van-cell {
  266. padding: 10px 0;
  267. border-bottom: 1px solid #ccc;
  268. }
  269. .van-field__label {
  270. width: 9em;
  271. }
  272. .sendCode {
  273. border: none !important;
  274. input {
  275. border: 1px solid #f1f1f1;
  276. height: 35px;
  277. }
  278. }
  279. .van-checkbox--horizontal {
  280. margin-bottom: 10px;
  281. width: 100%;
  282. }
  283. .van-radio--horizontal {
  284. margin-bottom: 10px;
  285. }
  286. }
  287. .footer-btn {
  288. display: flex;
  289. justify-content: space-around;
  290. padding: 10px 0;
  291. }
  292. }
  293. </style>