shopAdd.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <template>
  2. <div class="shopAdd">
  3. <el-dialog width="40%" :title="title" destroy-on-close center :visible.sync="showVisible">
  4. <el-form :model="form">
  5. <el-form-item label="门店名称" label-width="103px">
  6. <el-input v-model="form.name" placeholder="请输入店铺名称" autocomplete="off" style="width: 100%"></el-input>
  7. </el-form-item>
  8. <el-form-item label="主营类别" label-width="103px">
  9. <div class="category_box">
  10. <div class="item" :class="form.categoryId == item.id ? 'active':''" v-for="(item,i) in products" :key="i" @click="$set(form,'categoryId',item.id)">
  11. {{item.name}}
  12. </div>
  13. </div>
  14. </el-form-item>
  15. <el-form-item label="详细地址" label-width="103px">
  16. <el-input v-model="form.address" placeholder="请点击地图选择具体地址" disabled autocomplete="off" style="width: 100%">
  17. <el-image @click="showMap" slot="append" class="map" src="../../../static/image/icon_map.png"></el-image>
  18. </el-input>
  19. </el-form-item>
  20. <el-form-item label="门牌号" label-width="103px">
  21. <el-input v-model="form.street" placeholder="请填写门牌号" autocomplete="off" style="width: 100%">
  22. </el-input>
  23. </el-form-item>
  24. <el-form-item label="联系人姓名" label-width="103px">
  25. <el-input v-model="form.contactName" placeholder="请填写姓名" autocomplete="off" style="width: 40%"></el-input>
  26. </el-form-item>
  27. <el-form-item label="联系人电话" label-width="103px">
  28. <el-input v-model="form.mobile" placeholder="请填写手机号" autocomplete="off" style="width: 40%"></el-input>
  29. </el-form-item>
  30. <el-form-item label="已获运力" label-width="103px" v-if="form.id">
  31. <div class="logo_box">
  32. <div v-for="(item,i) in form.deliveries" :key="i">
  33. <img v-if="item.bindStatus == 1" :src="item.logo" alt="">
  34. </div>
  35. </div>
  36. <div class="line"></div>
  37. </el-form-item>
  38. <el-form-item label="审核中运力" label-width="103px" v-if="form.id && revieweds.length">
  39. <div class="reviewed">
  40. <div class="item" v-for="(item, i) in revieweds" :key="i">
  41. <div class="left">
  42. <img class="logo" :src="item.logo">
  43. <span class="label">{{item.name}}</span>
  44. </div>
  45. <div class="tip">审核中</div>
  46. </div>
  47. </div>
  48. </el-form-item>
  49. </el-form>
  50. <div slot="footer" class="dialog-footer">
  51. <el-button class="btn" @click="save">保存</el-button>
  52. </div>
  53. </el-dialog>
  54. <!-- 通过地图选择地理位置 -->
  55. <order-map @getAddressDetail="getAddressDetail" ref="orderMap"></order-map>
  56. </div>
  57. </template>
  58. <script>
  59. import orderMap from "../orderComponents/orderAMap.vue";
  60. import { shopAdd } from "../../api/shop.js";
  61. export default {
  62. props: {
  63. products: {
  64. type: Array,
  65. default: function () {
  66. return [];
  67. },
  68. },
  69. },
  70. data() {
  71. return {
  72. title: "新增门店",
  73. showVisible: false,
  74. form: {},
  75. revieweds: [],
  76. };
  77. },
  78. components: {
  79. orderMap,
  80. },
  81. methods: {
  82. init(e) {
  83. if (e) {
  84. console.log(e);
  85. this.title = "编辑门店";
  86. for (let i = 0; i < e.deliveries.length; i++) {
  87. if (e.deliveries[i].bindStatus == 2) {
  88. this.revieweds.push(e.deliveries[i]);
  89. }
  90. }
  91. this.form = e;
  92. } else {
  93. this.title = "新增门店";
  94. this.form = {};
  95. }
  96. this.showVisible = true;
  97. },
  98. showMap() {
  99. this.$refs.orderMap.chooseLocation();
  100. },
  101. getAddressDetail(v, lng, lat) {
  102. this.form.address = v.formattedAddress;
  103. this.form.provinceName = v.province;
  104. this.form.cityName = v.city;
  105. this.form.cityCode = v.citycode;
  106. this.form.districtName = v.district;
  107. this.form.lng = lng;
  108. this.form.lat = lat;
  109. },
  110. save() {
  111. shopAdd(this.form).then((res) => {
  112. if (res.code === 200) {
  113. this.$message({
  114. type: "success",
  115. message: `${this.form.id ? "保存" : "新增"}成功!`,
  116. });
  117. this.$emit("getData");
  118. } else {
  119. this.$message({
  120. type: "error",
  121. message: res.msg,
  122. });
  123. }
  124. });
  125. },
  126. },
  127. };
  128. </script>
  129. <style lang="scss">
  130. .shopAdd {
  131. .map {
  132. height: 25px;
  133. width: 25px;
  134. cursor: pointer;
  135. }
  136. .el-dialog {
  137. border-radius: 16px;
  138. overflow: hidden;
  139. }
  140. .el-dialog__headerbtn .el-dialog__close:hover {
  141. color: #909399;
  142. }
  143. .el-dialog__header {
  144. /*height: 48px;*/
  145. background: #f7f7f7;
  146. padding: 16px 20px;
  147. }
  148. .el-dialog__title {
  149. font-size: 16px;
  150. font-weight: 500;
  151. color: #000000;
  152. }
  153. .el-form-item__label {
  154. text-align: left;
  155. color: #000000;
  156. }
  157. .el-input__inner:focus {
  158. border-color: #fc7b0f;
  159. }
  160. .el-input__inner {
  161. color: #222222;
  162. }
  163. .category_box {
  164. display: flex;
  165. flex-wrap: wrap;
  166. width: 100%;
  167. margin-top: -10px;
  168. .item {
  169. display: flex;
  170. align-items: center;
  171. justify-content: center;
  172. width: 92px;
  173. height: 38px;
  174. margin: 10px 10px 0 0;
  175. background: #f4f4f4;
  176. border-radius: 2px;
  177. cursor: pointer;
  178. &.active {
  179. color: #ffffff;
  180. background: #fc7200;
  181. }
  182. }
  183. }
  184. .line {
  185. position: absolute;
  186. left: -103px;
  187. right: 0;
  188. bottom: -12px;
  189. border: 0.5px dashed #e0e0e0;
  190. }
  191. .logo_box {
  192. width: 100%;
  193. height: 40px;
  194. display: flex;
  195. align-items: center;
  196. line-height: 0;
  197. img {
  198. width: 20px;
  199. height: 20px;
  200. border-radius: 50%;
  201. margin-right: 10px;
  202. vertical-align: top;
  203. }
  204. }
  205. .reviewed {
  206. .item {
  207. display: flex;
  208. align-items: center;
  209. justify-content: space-between;
  210. height: 40px;
  211. .left {
  212. display: flex;
  213. align-items: center;
  214. line-height: 0;
  215. .logo {
  216. width: 20px;
  217. height: 20px;
  218. border-radius: 50%;
  219. margin-right: 10px;
  220. }
  221. .label {
  222. font-size: 14px;
  223. color: #000000;
  224. }
  225. }
  226. .tip {
  227. display: flex;
  228. align-items: center;
  229. justify-content: center;
  230. width: 60px;
  231. height: 22px;
  232. border-radius: 22px;
  233. background: #f74141;
  234. font-size: 12px;
  235. color: #ffffff;
  236. }
  237. }
  238. }
  239. .btn {
  240. width: 220px;
  241. }
  242. }
  243. </style>