myInfo.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <template>
  2. <view class="">
  3. <uni-section title="基本信息" style="padding: 0 62rpx;" titleColor="5F5F5F" titleFontSize="28rpx">
  4. <uni-forms ref="form1" :modelValue="form" :border="true" label-width="80">
  5. <uni-forms-item name="cname" label="店铺名称" required>
  6. <uni-easyinput v-model="form.cname" class="right-align" placeholder-class="placeholder-right"
  7. placeholder="请输入内容" :inputBorder="false" :clearable="false" >
  8. </uni-easyinput>
  9. </uni-forms-item>
  10. <uni-forms-item name="tel" label="电话" required>
  11. <uni-easyinput v-model="form.tel" class="right-align" type="number"
  12. placeholder-class="placeholder-right" placeholder="请输入内容" :inputBorder="false"
  13. :clearable="false" :disabled="true" maxlength="11"
  14. @change="photoChange"></uni-easyinput>
  15. </uni-forms-item>
  16. <uni-forms-item name="salesmanName" label="业务员" required>
  17. <view style="display: flex;align-items: center;height: 36px;">
  18. <view @click="getSalerList();salesmanShow=true"
  19. style="width: 100%;text-align: right;"
  20. :style="form.salesmanName?'color:#000;':'color:#B5B4B4;font-size: 24rpx;'">
  21. {{form.salesmanName||'请选择'}}
  22. </view>
  23. <uni-icons v-if="!form.salesmanName" type="down" size="14" color='#BCBCBC'
  24. @click="getSalerList();salesmanShow=true"></uni-icons>
  25. </view>
  26. <u-picker :show="salesmanShow" :columns="salesmanList" keyName="name" @confirm="salesmanConfirm"
  27. @cancel="salesmanShow=false" @close="salesmanShow=false" closeOnClickOverlay></u-picker>
  28. </uni-forms-item>
  29. <!-- <uni-forms-item name="deliveryWarehouseName" label="发货仓库" required>
  30. <view style="display: flex;align-items: center;height: 36px;">
  31. <view @click="getStorageList();deliveryWarehouseShow=true"
  32. style="width: 100%;text-align: right;"
  33. :style="form.deliveryWarehouseName?'color:#000;':'color:#B5B4B4;font-size: 24rpx;'">
  34. {{form.deliveryWarehouseName||'请选择'}}
  35. </view>
  36. <uni-icons v-if="!form.deliveryWarehouseName" type="down" size="14" color='#BCBCBC'
  37. @click="getStorageList();deliveryWarehouseShow=true"></uni-icons>
  38. </view>
  39. <u-picker :show="deliveryWarehouseShow" :columns="deliveryWarehouseList" keyName="cname"
  40. @confirm="deliveryWarehouseConfirm" @cancel="deliveryWarehouseShow=false"
  41. @close="deliveryWarehouseShow=false" closeOnClickOverlay></u-picker>
  42. </uni-forms-item>-->
  43. </uni-forms>
  44. </uni-section>
  45. <!-- <uni-section title="店面分类" style="padding: 0 62rpx;margin-top: 30rpx;" titleColor="5F5F5F" titleFontSize="28rpx">
  46. <uni-forms ref="form2" :modelValue="form" :border="true" label-width="80">
  47. <uni-forms-item name="corpsTypeName" label="店面分类" required>
  48. <view style="display: flex;align-items: center;height: 36px;">
  49. <view @click="getSelectType();corpsTypeShow=true"
  50. style="width: 100%;text-align: right;"
  51. :style="form.corpsTypeName?'color:#000;':'color:#B5B4B4;font-size: 24rpx;'">
  52. {{form.corpsTypeName||'请选择'}}
  53. </view>
  54. <uni-icons v-if="!form.corpsTypeName" type="down" size="14" color='#BCBCBC'
  55. @click="getSelectType();corpsTypeShow=true"></uni-icons>
  56. </view>
  57. <u-picker :show="corpsTypeShow" :columns="corpsTypeList" keyName="cname" @confirm="corpsTypeConfirm"
  58. @cancel="corpsTypeShow=false" @close="corpsTypeShow=false" closeOnClickOverlay></u-picker>
  59. </uni-forms-item>
  60. <uni-forms-item name="label" label="店面标签">
  61. <view>
  62. <view style="display: flex;align-items: center;height: 36px;">
  63. <view class="slot-box" @click="openPopup">
  64. <view v-for="(item,index) in sliceArray(form.label)" :key="index"
  65. class="slot-content-item">
  66. {{item}}
  67. </view>
  68. <view v-if="form.label.length > 2" class="slot-content-item">
  69. +{{form.label.length - 2}}</view>
  70. <view v-if="form.label.length == 0" style="color:#B5B4B4;font-size: 24rpx;">
  71. 请选择
  72. </view>
  73. </view>
  74. <uni-icons v-if="!form.label.length" type="down" size="14" color='#BCBCBC'
  75. @click="openPopup"></uni-icons>
  76. </view>
  77. <uni-popup ref="popup" type="bottom">
  78. <view class="popup-content">
  79. <view class="popup-content-checkbox">
  80. <scroll-view scroll-y="true" style="height: 600rpx;" :show-scrollbar="false">
  81. <uni-data-checkbox mode="tag" multiple v-model="form.label"
  82. :localdata="labelList" @change="onChange" selectedColor='#03803B'
  83. :map="labelObject" />
  84. </scroll-view>
  85. </view>
  86. <debounce-button class="confirm-btn" @click="labelConfirm">确认</debounce-button>
  87. </view>
  88. </uni-popup>
  89. </view>
  90. </uni-forms-item>
  91. </uni-forms>
  92. </uni-section>-->
  93. <view style="padding:30rpx 20rpx;">
  94. <debounce-button bgColor="#03803B" @click="submit">修改</debounce-button>
  95. </view>
  96. </view>
  97. </template>
  98. <script>
  99. import {
  100. submit,
  101. selectType,
  102. selectLabel,
  103. salerList,
  104. storageList,
  105. getAppDetails
  106. } from '@/api/home/store.js'
  107. export default {
  108. data() {
  109. return {
  110. corpsTypeShow: false,
  111. salesmanShow: false,
  112. deliveryWarehouseShow: false,
  113. form: {
  114. corpsTypeId: null,
  115. corpsTypeName: null,
  116. storeAttributes: null,
  117. chainAttribute: null,
  118. signingLevel: null,
  119. dimension: null,
  120. longitude: null,
  121. address: null,
  122. detailedAddress: null,
  123. label: [],
  124. brandName: [],
  125. },
  126. labelObject: {
  127. text: 'label',
  128. value: 'label',
  129. },
  130. labelList: [],
  131. corpsTypeList: [],
  132. salesmanList: [],
  133. brandList: [],
  134. deliveryWarehouseList: [],
  135. }
  136. },
  137. onLoad(option) {
  138. this.getSelectType()
  139. this.getLabel()
  140. this.getSalerList()
  141. // this.getStorageList()
  142. this.getAppDetails()
  143. },
  144. methods: {
  145. photoChange(val) {
  146. if (val) {
  147. if (!/^[1][3,4,5,7,8,9][0-9]{9}$/.test(val)) {
  148. uni.showToast({
  149. title: '请输入正确电话',
  150. icon: 'none'
  151. });
  152. return;
  153. }
  154. }
  155. },
  156. intBlur(name, value) {
  157. if (!this.form[name]) return
  158. // 使用toFixed处理小数位
  159. try {
  160. const num = parseFloat(this.form[name])
  161. if (!isNaN(num)) {
  162. this.form[name] = Math.floor(num).toFixed(0)
  163. }
  164. } catch (e) {
  165. console.error('格式化错误', e)
  166. }
  167. },
  168. openPopup() {
  169. this.getLabel()
  170. this.$refs.popup.open()
  171. },
  172. onChange(e) {
  173. console.log('当前选中:', e.detail.value)
  174. },
  175. brandChange(e) {
  176. console.log('当前选中:', e.detail)
  177. let ids = []
  178. e.detail.data.forEach(item => {
  179. ids.push(item.id)
  180. })
  181. this.form.brandId = ids.join(',')
  182. },
  183. labelConfirm() {
  184. this.$refs.popup.close()
  185. // 提交选中值逻辑...
  186. },
  187. brandConfirm() {
  188. this.$refs.brand.close()
  189. // 提交选中值逻辑...
  190. },
  191. clear(name) {
  192. if (name == 'corpsTypeName') {
  193. this.form.corpsTypeId = null
  194. this.form.corpsTypeName = null
  195. }
  196. if (name == 'salesmanName') {
  197. this.form.salesmanId = null
  198. this.form.salesmanName = null
  199. }
  200. if (name == 'deliveryWarehouseName') {
  201. this.form.deliveryWarehouseId = null
  202. this.form.deliveryWarehouseName = null
  203. }
  204. },
  205. salesmanConfirm(row) {
  206. this.form.salesmanId = row.value[0].id
  207. this.form.salesmanName = row.value[0].name
  208. this.salesmanShow = false
  209. },
  210. deliveryWarehouseConfirm(row) {
  211. this.form.deliveryWarehouseId = row.value[0].id
  212. this.form.deliveryWarehouseName = row.value[0].cname
  213. this.deliveryWarehouseShow = false
  214. },
  215. corpsTypeConfirm(row) {
  216. this.form.corpsTypeId = row.value[0].id
  217. this.form.corpsTypeName = row.value[0].cname
  218. this.corpsTypeShow = false
  219. },
  220. sliceArray(ls) {
  221. if (Array.isArray(ls)) {
  222. return ls.slice(0, 2)
  223. }
  224. return ls
  225. },
  226. getSelectType() {
  227. selectType().then(res => {
  228. this.corpsTypeList = [res.data]
  229. })
  230. },
  231. getLabel() {
  232. selectLabel().then(res => {
  233. this.labelList = res.data
  234. })
  235. },
  236. getSalerList() {
  237. salerList().then(res => {
  238. this.salesmanList = [res.data]
  239. })
  240. },
  241. getStorageList() {
  242. storageList().then(res => {
  243. this.deliveryWarehouseList = [res.data]
  244. })
  245. },
  246. getFileExtension(filename) {
  247. return filename.slice(((filename.lastIndexOf(".") - 1) >>> 0) + 2);
  248. },
  249. async submit() {
  250. if (!this.form.cname) {
  251. uni.showToast({
  252. title: '请输入店铺名称',
  253. icon: 'none'
  254. });
  255. return
  256. }
  257. if (!this.form.salesmanName) {
  258. uni.showToast({
  259. title: '请选择业务员',
  260. icon: 'none'
  261. });
  262. return
  263. }
  264. if (!this.form.deliveryWarehouseName) {
  265. uni.showToast({
  266. title: '请选择发货仓库',
  267. icon: 'none'
  268. });
  269. return
  270. }
  271. if (!this.form.corpsTypeId) {
  272. uni.showToast({
  273. title: '请选择店面分类',
  274. icon: 'none'
  275. });
  276. return
  277. }
  278. let obj = await this.convertData(this.$deepClone(this.form))
  279. uni.showLoading({
  280. title: '加载中',
  281. mask: true
  282. });
  283. submit(obj).then(res => {
  284. setTimeout(() => {
  285. uni.showToast({
  286. title: res.msg,
  287. icon: 'none',
  288. });
  289. }, 10);
  290. this.getAppDetails()
  291. })
  292. .catch(() => {
  293. uni.hideLoading()
  294. });
  295. },
  296. getAppDetails() {
  297. uni.showLoading({
  298. title: '加载中',
  299. mask: true
  300. });
  301. getAppDetails().then(res => {
  302. res.data.label = res.data.label ? res.data.label.split(",") : []
  303. this.form = res.data
  304. })
  305. .finally(() => {
  306. uni.hideLoading()
  307. });
  308. },
  309. async convertData(obj) {
  310. obj.label = obj.label ? obj.label.join(",") : null
  311. return obj
  312. }
  313. }
  314. }
  315. </script>
  316. <style lang="scss" scoped>
  317. .right-align {
  318. text-align: right;
  319. }
  320. .photo {
  321. margin-left: 20rpx;
  322. width: 38rpx;
  323. height: 32rpx;
  324. }
  325. ::v-deep .uni-section .uni-section-header {
  326. font-weight: bold !important;
  327. padding: 12px 0px !important;
  328. border-bottom: 2px solid #F6F6F6;
  329. }
  330. ::v-deep .uni-file-picker__container {
  331. justify-content: flex-end !important;
  332. }
  333. ::v-deep .uni-file-picker .file-picker__box-content {
  334. overflow: revert;
  335. z-index: 9;
  336. }
  337. ::v-deep .icon-del-box {
  338. height: 26rpx;
  339. width: 26rpx;
  340. top: -2rpx;
  341. right: -8rpx;
  342. z-index: 999;
  343. }
  344. ::v-deep .icon-del {
  345. width: 14rpx;
  346. height: 2rpx;
  347. }
  348. .slot-content-item {
  349. border-radius: 13rpx;
  350. border: 2rpx solid #03803B;
  351. padding: 1rpx 5rpx;
  352. color: #03803B;
  353. }
  354. .slot-content-item-placeholder {
  355. font-weight: 400 !important;
  356. font-size: 28rpx !important;
  357. height: 38rpx !important;
  358. color: #B5B4B4 !important;
  359. }
  360. .slot-box {
  361. gap: 5px;
  362. display: flex;
  363. flex-wrap: wrap;
  364. justify-content: flex-end;
  365. width: 100%;
  366. }
  367. .popup-content {
  368. background: #fff;
  369. padding: 40rpx 20rpx;
  370. border-radius: 24rpx 24rpx 0 0;
  371. }
  372. .popup-content-checkbox {
  373. height: 600rpx;
  374. }
  375. .confirm-btn {
  376. margin-top: 30rpx;
  377. color: #ffffff;
  378. background: #03803B;
  379. width: 400rpx;
  380. }
  381. ::v-deep .icon-add {
  382. width: 36px !important;
  383. }
  384. ::v-deep .uni-date-x .uni-icons {
  385. color: #03803B !important;
  386. }
  387. </style>