JPattributeEditor.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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-field label="是否有工地资源(支持工地配送,承接工地双包等)">
  79. <template #input>
  80. <van-radio-group
  81. v-model="detail.constructionResource"
  82. direction="horizontal"
  83. @change="changeResource">
  84. <van-radio name="是">是</van-radio>
  85. <van-radio name="否">否</van-radio>
  86. </van-radio-group>
  87. </template>
  88. </van-field>
  89. <van-field
  90. v-if="detail.constructionResource == '是'"
  91. v-model="detail.constructionYearNum"
  92. type="number"
  93. label="年工地数量" />
  94. <van-field label="是否有双包能力">
  95. <template #input>
  96. <van-radio-group v-model="detail.doubleContracting" direction="horizontal">
  97. <van-radio name="是">是</van-radio>
  98. <van-radio name="否">否</van-radio>
  99. </van-radio-group>
  100. </template>
  101. </van-field>
  102. </van-form>
  103. </div>
  104. <div class="footer-btn">
  105. <van-button
  106. style="color: white; background: rgb(0, 87, 186); border-radius: 6px; width: 90%"
  107. @click="confirmShare">
  108. 保 存
  109. </van-button>
  110. </div>
  111. <!-- 时间选择 -->
  112. <van-popup v-model="datetimeShowPicker" position="bottom">
  113. <van-datetime-picker
  114. v-model="currentDate"
  115. type="date"
  116. title="选择年月日"
  117. :min-date="minDate"
  118. :max-date="maxDate"
  119. @confirm="datetimeOnConfirm"
  120. @cancel="datetimeShowPicker = false" />
  121. </van-popup>
  122. </div>
  123. </template>
  124. <script>
  125. import { sendAndCheckVerCode, getDictOption } from '@/api/index';
  126. import { getStoreArchives, updateArchives } from '@/api/storeManagement';
  127. export default {
  128. name: 'JPattributeEditor',
  129. data() {
  130. return {
  131. detail: null,
  132. time: null, //计时
  133. timeNum: 60,
  134. verificationVal: '',
  135. datetimeShowPicker: false,
  136. activatNyrItem: '',
  137. checkboxGroup: [],
  138. mainProductCategorys: [],
  139. emergencyContactRelation: [],
  140. verificationPassedPhoneNum: '', //验证通过手机号
  141. minDate: new Date(1945, 0, 1),
  142. maxDate: new Date(),
  143. currentDate: new Date(1945, 0, 1),
  144. mobileStatus: '0',
  145. verifyMobile: false, //手机号是否验证透通过
  146. };
  147. },
  148. activated() {
  149. this.detail = null;
  150. this.verificationVal = '';
  151. if (this.time) clearInterval(this.time);
  152. this.time = null; //计时
  153. this.timeNum = 60;
  154. this.toastLoading(0, '加载中...', true);
  155. getDictOption({}, 'archives_main_product_categorys').then((res) => {
  156. let mainProductCategorys = [];
  157. let emergencyContactRelation = [];
  158. res.data.forEach((val) => {
  159. if (val.remark == 'mainProductCategorys') {
  160. mainProductCategorys.push(val);
  161. } else {
  162. emergencyContactRelation.push(val);
  163. }
  164. });
  165. this.mainProductCategorys = mainProductCategorys;
  166. this.emergencyContactRelation = emergencyContactRelation;
  167. this.getDetaild();
  168. });
  169. },
  170. methods: {
  171. getDetaild() {
  172. getStoreArchives({ storeCode: this.$route.query.storeCode }).then((res) => {
  173. this.toastLoading().clear();
  174. if (res.code == 200) {
  175. // let copyData = JSON.parse(JSON.stringify(res.data));
  176. res.data.mainProductCategorys = res.data.mainProductCategorys
  177. ? res.data.mainProductCategorys.split(',')
  178. : [];
  179. this.detail = res.data;
  180. this.mobileStatus = res.data.mobileStatus;
  181. // mobileStatus 1是 是否验证通过
  182. if (res.data.mobileStatus == '1') {
  183. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  184. }
  185. // 验证码和发送按钮是否显示
  186. this.verifyMobile = this.mobileStatus == '0' ? false : true;
  187. }
  188. });
  189. },
  190. sendCodeTelFn(tel) {
  191. if (!/^1[123456789]\d{9}$/.test(tel) || tel == '') {
  192. this.$toast('格式错误');
  193. return;
  194. }
  195. if (tel != this.verificationPassedPhoneNum) {
  196. this.verifyMobile = false;
  197. }
  198. },
  199. // 发送验证码
  200. sendCode(val) {
  201. if (!/^1[123456789]\d{9}$/.test(val) || val == '') {
  202. this.$toast('格式错误');
  203. return;
  204. }
  205. if (this.time) return;
  206. clearInterval(this.time);
  207. this.timeNum = 60;
  208. this.sendCodeFun(
  209. {
  210. type: '1', //String 调用类型:1:发送验证码 2:校验验证码
  211. phone: val, //String 手机号
  212. verification: '', //String 手机号验证码
  213. },
  214. () => {
  215. this.time = setInterval(() => {
  216. this.timeNum--;
  217. if (this.timeNum <= 0) {
  218. clearInterval(this.time);
  219. this.time = null;
  220. }
  221. }, 1000);
  222. this.$toast('发送成功');
  223. }
  224. );
  225. },
  226. sendCodeFun(params, callback) {
  227. sendAndCheckVerCode(params).then((res) => {
  228. if (res.code == 200) {
  229. callback && callback(res);
  230. }
  231. });
  232. },
  233. verification(val) {
  234. // 验证码
  235. if (val == '') {
  236. return;
  237. }
  238. // 手机号
  239. if (this.detail.ownerMobile == '') {
  240. return;
  241. }
  242. this.sendCodeFun(
  243. {
  244. type: '2', //String 调用类型:1:发送验证码 2:校验验证码
  245. phone: this.detail.ownerMobile, //String 手机号
  246. verification: val, //String 手机号验证码
  247. },
  248. (res) => {
  249. if (res.data) this.verificationPassedPhoneNum = this.detail.ownerMobile;
  250. this.$toast(res.data ? '验证成功' : '验证码错误');
  251. }
  252. );
  253. },
  254. getNyr(val, date) {
  255. this.activatNyrItem = val;
  256. if (date && date != '') {
  257. let time = date.split('-');
  258. this.currentDate = new Date(time[0], Number(time[1]) - 1, time[2]);
  259. } else {
  260. this.currentDate = new Date(1945, 0, 1);
  261. }
  262. this.datetimeShowPicker = true;
  263. },
  264. datetimeOnConfirm(time) {
  265. this.$set(this.detail, this.activatNyrItem, this.parseTime(time, '{y}-{m}-{d}'));
  266. // this.detail.ownerBirthday = this.parseTime(time, '{y}-{m}-{d}');
  267. this.datetimeShowPicker = false;
  268. },
  269. // 保存
  270. confirmShare() {
  271. if (
  272. this.verificationPassedPhoneNum == '' ||
  273. this.detail.ownerMobile != this.verificationPassedPhoneNum
  274. ) {
  275. this.$toast('请验证手机号');
  276. return;
  277. }
  278. if (this.detail.emergencyContactMobile != '') {
  279. if (!/^1[123456789]\d{9}$/.test(this.detail.emergencyContactMobile)) {
  280. this.$toast('紧急联系人电话格式错误');
  281. return;
  282. }
  283. }
  284. this.toastLoading(0, '加载中...', true);
  285. let params = JSON.parse(JSON.stringify(this.detail));
  286. params.mainProductCategorys = params.mainProductCategorys.join(',');
  287. params.storeCode = this.$route.query.storeCode;
  288. updateArchives(params).then((res) => {
  289. this.toastLoading().clear();
  290. if (res.code == 200) {
  291. this.$toast(res.msg);
  292. this.$router.go(-1);
  293. } else {
  294. this.$toast(res.msg);
  295. }
  296. });
  297. },
  298. emergencyContactBlur(val) {
  299. if (!/^1[123456789]\d{9}$/.test(val)) {
  300. this.$toast('紧急联系人电话格式错误');
  301. }
  302. },
  303. changeResource(val) {
  304. if (val == '否') {
  305. this.detail.constructionYearNum = '';
  306. }
  307. },
  308. onClickLeft() {
  309. this.$router.go(-1);
  310. },
  311. },
  312. };
  313. </script>
  314. <style lang="scss">
  315. .JPattributeEditor {
  316. width: 100%;
  317. height: 100%;
  318. display: flex;
  319. flex-direction: column;
  320. justify-content: space-between;
  321. overflow: hidden;
  322. .content {
  323. flex: 1;
  324. overflow-y: auto;
  325. background: #fff;
  326. padding: 10px 15px;
  327. margin-top: 10px;
  328. background: #fff;
  329. .van-cell {
  330. padding: 10px 0;
  331. border-bottom: 1px solid #ccc;
  332. }
  333. .van-field__label {
  334. width: 9em;
  335. }
  336. .sendCode {
  337. border: none !important;
  338. input {
  339. border: 1px solid #f1f1f1;
  340. height: 35px;
  341. }
  342. }
  343. .van-checkbox--horizontal {
  344. margin-bottom: 10px;
  345. width: 100%;
  346. }
  347. .van-radio--horizontal {
  348. margin-bottom: 10px;
  349. }
  350. }
  351. .footer-btn {
  352. display: flex;
  353. justify-content: space-around;
  354. padding: 10px 0;
  355. }
  356. }
  357. </style>