JPattributeEditor.vue 9.2 KB

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