JPattributeEditor.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. this.detail = null;
  118. this.verificationVal = '';
  119. if (this.time) clearInterval(this.time);
  120. this.time = null; //计时
  121. this.timeNum = 60;
  122. this.toastLoading(0, '加载中...', true);
  123. getDictOption({}, 'archives_main_product_categorys').then((res) => {
  124. let mainProductCategorys = [];
  125. let emergencyContactRelation = [];
  126. res.data.forEach((val) => {
  127. if (val.remark == 'mainProductCategorys') {
  128. mainProductCategorys.push(val);
  129. } else {
  130. emergencyContactRelation.push(val);
  131. }
  132. });
  133. this.mainProductCategorys = mainProductCategorys;
  134. this.emergencyContactRelation = emergencyContactRelation;
  135. this.getDetaild();
  136. });
  137. },
  138. methods: {
  139. getDetaild() {
  140. getStoreArchives({ storeCode: this.$route.query.storeCode }).then((res) => {
  141. this.toastLoading().clear();
  142. if (res.code == 200) {
  143. // let copyData = JSON.parse(JSON.stringify(res.data));
  144. res.data.mainProductCategorys = res.data.mainProductCategorys
  145. ? res.data.mainProductCategorys.split(',')
  146. : [];
  147. this.detail = res.data;
  148. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  149. }
  150. });
  151. },
  152. // 发送验证码
  153. sendCode(val) {
  154. if (!/^1[3456789]\d{9}$/.test(val) || val == '') {
  155. this.$toast('格式错误');
  156. return;
  157. }
  158. if (this.time) return;
  159. clearInterval(this.time);
  160. this.timeNum = 60;
  161. this.sendCodeFun(
  162. {
  163. type: '1', //String 调用类型:1:发送验证码 2:校验验证码
  164. phone: val, //String 手机号
  165. verification: '', //String 手机号验证码
  166. },
  167. () => {
  168. this.time = setInterval(() => {
  169. this.timeNum--;
  170. if (this.timeNum <= 0) {
  171. clearInterval(this.time);
  172. this.time = null;
  173. }
  174. }, 1000);
  175. this.$toast('发送成功');
  176. }
  177. );
  178. },
  179. sendCodeFun(params, callback) {
  180. sendAndCheckVerCode(params).then((res) => {
  181. if (res.code == 200) {
  182. callback && callback(res);
  183. }
  184. });
  185. },
  186. verification(val) {
  187. // 验证码
  188. if (val == '') {
  189. return;
  190. }
  191. // 手机号
  192. if (this.detail.ownerMobile == '') {
  193. return;
  194. }
  195. this.sendCodeFun(
  196. {
  197. type: '2', //String 调用类型:1:发送验证码 2:校验验证码
  198. phone: this.detail.ownerMobile, //String 手机号
  199. verification: val, //String 手机号验证码
  200. },
  201. (res) => {
  202. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  203. this.$toast(res.data ? '验证成功' : '验证码错误');
  204. }
  205. );
  206. },
  207. getNyr(val, date) {
  208. this.activatNyrItem = val;
  209. if (date && date != '') {
  210. let time = date.split('-');
  211. this.currentDate = new Date(time[0], Number(time[1]) - 1, time[2]);
  212. } else {
  213. this.currentDate = new Date(1945, 0, 1);
  214. }
  215. this.datetimeShowPicker = true;
  216. },
  217. datetimeOnConfirm(time) {
  218. this.$set(this.detail, this.activatNyrItem, this.parseTime(time, '{y}-{m}-{d}'));
  219. // this.detail.ownerBirthday = this.parseTime(time, '{y}-{m}-{d}');
  220. this.datetimeShowPicker = false;
  221. },
  222. // 保存
  223. confirmShare() {
  224. if (this.detail.ownerMobile != this.verificationPassedPhoneNum) {
  225. this.$toast('请验证手机号');
  226. return;
  227. }
  228. this.toastLoading(0, '加载中...', true);
  229. let params = JSON.parse(JSON.stringify(this.detail));
  230. params.mainProductCategorys = params.mainProductCategorys.join(',');
  231. params.storeCode = this.$route.query.storeCode;
  232. updateArchives(params).then((res) => {
  233. this.toastLoading().clear();
  234. if (res.code == 200) {
  235. this.$toast(res.msg);
  236. this.$router.go(-1);
  237. } else {
  238. this.$toast(res.msg);
  239. }
  240. });
  241. },
  242. emergencyContactBlur(val) {
  243. if (!/^1[3456789]\d{9}$/.test(val)) {
  244. this.$toast('格式错误');
  245. }
  246. },
  247. onClickLeft() {
  248. this.$router.go(-1);
  249. },
  250. },
  251. };
  252. </script>
  253. <style lang="scss">
  254. .JPattributeEditor {
  255. width: 100%;
  256. height: 100%;
  257. display: flex;
  258. flex-direction: column;
  259. justify-content: space-between;
  260. overflow: hidden;
  261. .content {
  262. flex: 1;
  263. overflow-y: auto;
  264. background: #fff;
  265. padding: 10px 15px;
  266. margin-top: 10px;
  267. background: #fff;
  268. .van-cell {
  269. padding: 10px 0;
  270. border-bottom: 1px solid #ccc;
  271. }
  272. .van-field__label {
  273. width: 9em;
  274. }
  275. .sendCode {
  276. border: none !important;
  277. input {
  278. border: 1px solid #f1f1f1;
  279. height: 35px;
  280. }
  281. }
  282. .van-checkbox--horizontal {
  283. margin-bottom: 10px;
  284. width: 100%;
  285. }
  286. .van-radio--horizontal {
  287. margin-bottom: 10px;
  288. }
  289. }
  290. .footer-btn {
  291. display: flex;
  292. justify-content: space-around;
  293. padding: 10px 0;
  294. }
  295. }
  296. </style>