shopAdd.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <div class="shopAdd">
  3. <el-dialog width="600px" :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 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-item">
  40. <div class="item" v-for="(item, i) in revieweds" :key="i">
  41. <div class="left-wrap">
  42. <div class="left">
  43. <img class="logo" :src="item.logo">
  44. <span class="label">{{item.name}}</span>
  45. </div>
  46. <div class="tip">{{showStatus(item.bindStatus,item.authMsg)}}</div>
  47. </div>
  48. <div v-show="item.authMsg && item.bindStatus !== 1 && item.bindStatus !== 2" class="reason">原因:{{item.authMsg}}</div>
  49. </div>
  50. </div>
  51. </el-form-item>
  52. </el-form>
  53. <div slot="footer" class="dialog-footer">
  54. <el-button :loading="loading" class="btn" @click="save">保存</el-button>
  55. </div>
  56. </el-dialog>
  57. <!-- 通过地图选择地理位置 -->
  58. <order-map @getAddressDetail="getAddressDetail" ref="orderMap"></order-map>
  59. </div>
  60. </template>
  61. <script>
  62. import orderMap from "../orderComponents/orderAMap.vue";
  63. import { getShopDetail, shopAdd, shopEdit } from "../../api/shop.js";
  64. export default {
  65. props: {
  66. products: {
  67. type: Array,
  68. default: function () {
  69. return [];
  70. },
  71. },
  72. },
  73. data() {
  74. return {
  75. title: "新增门店",
  76. showVisible: false,
  77. form: {
  78. id: "",
  79. address: "",
  80. cityCode: "",
  81. cityName: "",
  82. contactName: "",
  83. districtName: "",
  84. lat: "",
  85. lng: "",
  86. mobile: "",
  87. name: "",
  88. street: "",
  89. categoryId: "",
  90. },
  91. deliveries: [],
  92. revieweds: [],
  93. loading: false,
  94. };
  95. },
  96. components: {
  97. orderMap,
  98. },
  99. methods: {
  100. init(e) {
  101. if (e) {
  102. this.title = "编辑门店";
  103. getShopDetail({ shopId: e.id }).then((res) => {
  104. console.log(res);
  105. if (res.code === 200) {
  106. this.form = res.data;
  107. this.deliveries = this.form.deliveries.filter((v) => {
  108. return v.bindStatus === 1 && v.type !== 3;
  109. });
  110. this.revieweds = this.form.deliveries.filter((v) => {
  111. return v.type === 3;
  112. });
  113. } else {
  114. this.$message({
  115. type: "error",
  116. message: res.msg,
  117. });
  118. }
  119. });
  120. } else {
  121. this.title = "新增门店";
  122. this.form = {
  123. address: "",
  124. contactName: "",
  125. mobile: "",
  126. name: "",
  127. street: "",
  128. categoryId: "",
  129. };
  130. }
  131. this.showVisible = true;
  132. },
  133. showStatus(showStatus, authMsg) {
  134. let name = "";
  135. switch (showStatus) {
  136. case 0:
  137. if (authMsg) {
  138. name = "审核失败";
  139. } else {
  140. name = "未绑定";
  141. }
  142. break;
  143. case 1:
  144. name = "已通过";
  145. break;
  146. case 2:
  147. name = "审核中";
  148. break;
  149. case 3:
  150. name = "审核失败";
  151. break;
  152. default:
  153. break;
  154. }
  155. return name;
  156. },
  157. showMap() {
  158. this.$refs.orderMap.chooseLocation();
  159. },
  160. getAddressDetail(v, lng, lat) {
  161. this.form.address = v.address;
  162. this.form.provinceName = v.province;
  163. this.form.cityName = v.city;
  164. this.form.cityCode = v.citycode;
  165. this.form.districtName = v.district;
  166. this.form.lng = lng;
  167. this.form.lat = lat;
  168. },
  169. save() {
  170. if (!this.form.name.trim()) {
  171. return this.$message({
  172. type: "error",
  173. message: "请输入门店名称!",
  174. });
  175. }
  176. if (!String(this.form.categoryId).trim()) {
  177. return this.$message({
  178. type: "error",
  179. message: "请选择主营类别!",
  180. });
  181. }
  182. if (!this.form.address.trim()) {
  183. return this.$message({
  184. type: "error",
  185. message: "请选择详细地址!",
  186. });
  187. }
  188. if (!this.form.street.trim()) {
  189. return this.$message({
  190. type: "error",
  191. message: "请输入门牌号!",
  192. });
  193. }
  194. if (!this.form.contactName.trim()) {
  195. return this.$message({
  196. type: "error",
  197. message: "请输入联系人姓名!",
  198. });
  199. }
  200. if (!this.form.mobile.trim()) {
  201. return this.$message({
  202. type: "error",
  203. message: "请输入联系人电话!",
  204. });
  205. }
  206. this.loading = true;
  207. if (this.form.id) {
  208. shopEdit(this.form).then((res) => {
  209. if (res.code === 200) {
  210. this.$message({
  211. type: "success",
  212. message: `保存成功!`,
  213. });
  214. this.$emit("getData");
  215. } else {
  216. this.$message({
  217. type: "error",
  218. message: res.msg,
  219. });
  220. }
  221. this.showVisible = false;
  222. this.loading = false;
  223. });
  224. } else {
  225. shopAdd(this.form).then((res) => {
  226. if (res.code === 200) {
  227. this.$message({
  228. type: "success",
  229. message: `新增成功!`,
  230. });
  231. this.$emit("getData");
  232. } else {
  233. this.$message({
  234. type: "error",
  235. message: res.msg,
  236. });
  237. }
  238. this.showVisible = false;
  239. this.loading = false;
  240. });
  241. }
  242. },
  243. },
  244. };
  245. </script>
  246. <style lang="scss">
  247. .shopAdd {
  248. .map {
  249. height: 25px;
  250. width: 25px;
  251. cursor: pointer;
  252. }
  253. .el-dialog {
  254. border-radius: 16px;
  255. overflow: hidden;
  256. }
  257. .el-dialog__headerbtn .el-dialog__close:hover {
  258. color: #909399;
  259. }
  260. .el-dialog__header {
  261. /*height: 48px;*/
  262. background: #f7f7f7;
  263. padding: 16px 20px;
  264. }
  265. .el-dialog__title {
  266. font-size: 16px;
  267. font-weight: 500;
  268. color: #000000;
  269. }
  270. .el-form-item__label {
  271. text-align: left;
  272. color: #000000;
  273. }
  274. .el-input__inner:focus {
  275. border-color: #fc7b0f;
  276. }
  277. .el-input__inner {
  278. color: #222222;
  279. }
  280. .category_box {
  281. display: flex;
  282. flex-wrap: wrap;
  283. width: 100%;
  284. margin-top: -10px;
  285. .item {
  286. display: flex;
  287. align-items: center;
  288. justify-content: center;
  289. width: 92px;
  290. height: 38px;
  291. margin: 10px 10px 0 0;
  292. background: #f4f4f4;
  293. border-radius: 2px;
  294. cursor: pointer;
  295. &.active {
  296. color: #ffffff;
  297. background: #fc7200;
  298. }
  299. }
  300. }
  301. .line {
  302. position: absolute;
  303. left: -103px;
  304. right: 0;
  305. bottom: -12px;
  306. border: 0.5px dashed #e0e0e0;
  307. }
  308. .logo_box {
  309. width: 100%;
  310. height: 40px;
  311. display: flex;
  312. align-items: center;
  313. line-height: 0;
  314. img {
  315. width: 20px;
  316. height: 20px;
  317. border-radius: 50%;
  318. margin-right: 10px;
  319. vertical-align: top;
  320. }
  321. }
  322. .reviewed-item {
  323. .item {
  324. .reason {
  325. font-size: 12px;
  326. color: crimson;
  327. }
  328. .left-wrap {
  329. display: flex;
  330. align-items: center;
  331. justify-content: space-between;
  332. height: 40px;
  333. .left {
  334. display: flex;
  335. align-items: center;
  336. line-height: 0;
  337. .logo {
  338. width: 20px;
  339. height: 20px;
  340. border-radius: 50%;
  341. margin-right: 10px;
  342. }
  343. .label {
  344. font-size: 14px;
  345. color: #000000;
  346. }
  347. }
  348. }
  349. .tip {
  350. display: flex;
  351. align-items: center;
  352. justify-content: center;
  353. width: 60px;
  354. height: 22px;
  355. border-radius: 22px;
  356. background: #f74141;
  357. font-size: 12px;
  358. color: #ffffff;
  359. }
  360. }
  361. }
  362. .btn {
  363. width: 220px;
  364. background: #fc7200;
  365. color: #ffffff;
  366. border-color: #fc7200;
  367. }
  368. }
  369. </style>