JPattributeEditor.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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
  59. v-model="detail.constructionResource"
  60. direction="horizontal"
  61. @change="changeResource">
  62. <van-radio name="是">是</van-radio>
  63. <van-radio name="否">否</van-radio>
  64. </van-radio-group>
  65. </template>
  66. </van-field>
  67. <van-field
  68. v-if="detail.constructionResource == '是'"
  69. v-model="detail.constructionYearNum"
  70. type="number"
  71. label="年工地数量" />
  72. <van-field label="是否有双包能力">
  73. <template #input>
  74. <van-radio-group v-model="detail.doubleContracting" direction="horizontal">
  75. <van-radio name="是">是</van-radio>
  76. <van-radio name="否">否</van-radio>
  77. </van-radio-group>
  78. </template>
  79. </van-field>
  80. <van-field label="紧急联系人身份">
  81. <template #input>
  82. <van-radio-group v-model="detail.emergencyContactRelation" direction="horizontal">
  83. <van-radio
  84. v-for="(item, index) in emergencyContactRelation"
  85. :name="item.dictValue"
  86. :key="index">
  87. {{ item.dictValue }}
  88. </van-radio>
  89. </van-radio-group>
  90. </template>
  91. </van-field>
  92. <van-field v-model="detail.emergencyContact" label="紧急联系人姓名" />
  93. <van-field
  94. v-model="detail.emergencyContactBirthday"
  95. label="紧急联系人出生日期"
  96. @click="getNyr('emergencyContactBirthday', detail.emergencyContactBirthday)" />
  97. <van-field
  98. v-model="detail.emergencyContactMobile"
  99. type="number"
  100. @blur="emergencyContactBlur(detail.emergencyContactMobile)"
  101. label="紧急联系人电话" />
  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. checkRadioFlag: false,
  147. };
  148. },
  149. activated() {
  150. this.detail = null;
  151. this.verificationVal = '';
  152. if (this.time) clearInterval(this.time);
  153. this.time = null; //计时
  154. this.timeNum = 60;
  155. this.toastLoading(0, '加载中...', true);
  156. getDictOption({}, 'archives_main_product_categorys').then((res) => {
  157. let mainProductCategorys = [];
  158. let emergencyContactRelation = [];
  159. res.data.forEach((val) => {
  160. if (val.remark == 'mainProductCategorys') {
  161. mainProductCategorys.push(val);
  162. } else {
  163. emergencyContactRelation.push(val);
  164. }
  165. });
  166. this.mainProductCategorys = mainProductCategorys;
  167. this.emergencyContactRelation = emergencyContactRelation;
  168. this.getDetaild();
  169. });
  170. },
  171. methods: {
  172. getDetaild() {
  173. getStoreArchives({ storeCode: this.$route.query.storeCode }).then((res) => {
  174. this.toastLoading().clear();
  175. if (res.code == 200) {
  176. // let copyData = JSON.parse(JSON.stringify(res.data));
  177. res.data.mainProductCategorys = res.data.mainProductCategorys
  178. ? res.data.mainProductCategorys.split(',')
  179. : [];
  180. this.detail = res.data;
  181. this.mobileStatus = res.data.mobileStatus;
  182. // mobileStatus 1是 是否验证通过
  183. if (res.data.mobileStatus == '1') {
  184. this.verificationPassedPhoneNum = this.detail.ownerMobile;
  185. }
  186. // 验证码和发送按钮是否显示
  187. this.verifyMobile = this.mobileStatus == '0' ? false : true;
  188. }
  189. });
  190. },
  191. sendCodeTelFn(tel) {
  192. if (!/^1[123456789]\d{9}$/.test(tel) || tel == '') {
  193. this.$toast('格式错误');
  194. return;
  195. }
  196. if (tel != this.verificationPassedPhoneNum) {
  197. this.verifyMobile = false;
  198. }
  199. },
  200. // 发送验证码
  201. sendCode(val) {
  202. if (!/^1[123456789]\d{9}$/.test(val) || val == '') {
  203. this.$toast('格式错误');
  204. return;
  205. }
  206. if (this.time) return;
  207. clearInterval(this.time);
  208. this.timeNum = 60;
  209. this.sendCodeFun(
  210. {
  211. type: '1', //String 调用类型:1:发送验证码 2:校验验证码
  212. phone: val, //String 手机号
  213. verification: '', //String 手机号验证码
  214. },
  215. () => {
  216. this.time = setInterval(() => {
  217. this.timeNum--;
  218. if (this.timeNum <= 0) {
  219. clearInterval(this.time);
  220. this.time = null;
  221. }
  222. }, 1000);
  223. this.$toast('发送成功');
  224. }
  225. );
  226. },
  227. sendCodeFun(params, callback) {
  228. sendAndCheckVerCode(params).then((res) => {
  229. if (res.code == 200) {
  230. callback && callback(res);
  231. }
  232. });
  233. },
  234. verification(val) {
  235. // 验证码
  236. if (val == '') {
  237. return;
  238. }
  239. // 手机号
  240. if (this.detail.ownerMobile == '') {
  241. return;
  242. }
  243. this.sendCodeFun(
  244. {
  245. type: '2', //String 调用类型:1:发送验证码 2:校验验证码
  246. phone: this.detail.ownerMobile, //String 手机号
  247. verification: val, //String 手机号验证码
  248. },
  249. (res) => {
  250. if (res.data) this.verificationPassedPhoneNum = this.detail.ownerMobile;
  251. this.$toast(res.data ? '验证成功' : '验证码错误');
  252. }
  253. );
  254. },
  255. getNyr(val, date) {
  256. this.activatNyrItem = val;
  257. if (date && date != '') {
  258. let time = date.split('-');
  259. this.currentDate = new Date(time[0], Number(time[1]) - 1, time[2]);
  260. } else {
  261. this.currentDate = new Date(1945, 0, 1);
  262. }
  263. this.datetimeShowPicker = true;
  264. },
  265. datetimeOnConfirm(time) {
  266. this.$set(this.detail, this.activatNyrItem, this.parseTime(time, '{y}-{m}-{d}'));
  267. // this.detail.ownerBirthday = this.parseTime(time, '{y}-{m}-{d}');
  268. this.datetimeShowPicker = false;
  269. },
  270. // 保存
  271. confirmShare() {
  272. if (
  273. this.verificationPassedPhoneNum == '' ||
  274. this.detail.ownerMobile != this.verificationPassedPhoneNum
  275. ) {
  276. this.$toast('请验证手机号');
  277. return;
  278. }
  279. if (this.detail.emergencyContactMobile != '') {
  280. if (!/^1[123456789]\d{9}$/.test(this.detail.emergencyContactMobile)) {
  281. this.$toast('紧急联系人电话格式错误');
  282. return;
  283. }
  284. }
  285. this.toastLoading(0, '加载中...', true);
  286. let params = JSON.parse(JSON.stringify(this.detail));
  287. params.mainProductCategorys = params.mainProductCategorys.join(',');
  288. params.storeCode = this.$route.query.storeCode;
  289. updateArchives(params).then((res) => {
  290. this.toastLoading().clear();
  291. if (res.code == 200) {
  292. this.$toast(res.msg);
  293. this.$router.go(-1);
  294. } else {
  295. this.$toast(res.msg);
  296. }
  297. });
  298. },
  299. emergencyContactBlur(val) {
  300. if (!/^1[123456789]\d{9}$/.test(val)) {
  301. this.$toast('紧急联系人电话格式错误');
  302. }
  303. },
  304. clickFn() {
  305. if (!this.checkRadioFlag) {
  306. this.detail.emergencyContactRelation = '';
  307. }
  308. this.checkRadioFlag = false;
  309. },
  310. changeFn() {
  311. this.checkRadioFlag = true;
  312. },
  313. changeResource(val) {
  314. if (val == '否') {
  315. this.detail.constructionYearNum = '';
  316. }
  317. },
  318. onClickLeft() {
  319. this.$router.go(-1);
  320. },
  321. },
  322. };
  323. </script>
  324. <style lang="scss">
  325. .JPattributeEditor {
  326. width: 100%;
  327. height: 100%;
  328. display: flex;
  329. flex-direction: column;
  330. justify-content: space-between;
  331. overflow: hidden;
  332. .content {
  333. flex: 1;
  334. overflow-y: auto;
  335. background: #fff;
  336. padding: 10px 15px;
  337. margin-top: 10px;
  338. background: #fff;
  339. .van-cell {
  340. padding: 10px 0;
  341. border-bottom: 1px solid #ccc;
  342. }
  343. .van-field__label {
  344. width: 9em;
  345. }
  346. .sendCode {
  347. border: none !important;
  348. input {
  349. border: 1px solid #f1f1f1;
  350. height: 35px;
  351. }
  352. }
  353. .van-checkbox--horizontal {
  354. margin-bottom: 10px;
  355. width: 100%;
  356. }
  357. .van-radio--horizontal {
  358. margin-bottom: 10px;
  359. }
  360. }
  361. .footer-btn {
  362. display: flex;
  363. justify-content: space-around;
  364. padding: 10px 0;
  365. }
  366. }
  367. </style>