JPattributeEditor.vue 10 KB

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