多租户商城-商户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

380 lines
12 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <template>
  2. <div class="module-box link-select" :class="styleType && 'style'+styleType">
  3. <div class="link-select__warp">
  4. <div class="module-box__title">
  5. <label class="module-box__label">{{title}}</label>
  6. </div>
  7. <el-select class="link-select__select" :popper-append-to-body="false" v-model="selsectValue" placeholder="请选择跳转到的页面" @change="selectChanged">
  8. <el-option
  9. v-for="item in options"
  10. :key="item.value"
  11. :label="item.label"
  12. :value="item.value">
  13. </el-option>
  14. </el-select>
  15. </div>
  16. <div class="link-select__confirm" v-show="confirmBtnVisible">
  17. <div class="btn" v-if="!selectName" @click="openDialog">
  18. <span class="iconfont">&#xe685;</span> 添加{{typeText}}
  19. </div>
  20. <div class="info" v-else>
  21. <span class="text">{{typeText}}</span>
  22. <span class="name">{{selectName}}</span>
  23. <span class="iconfont" @click="openDialog">&#xe66c;</span>
  24. <span class="iconfont" @click="delSelect">&#xe651;</span>
  25. </div>
  26. </div>
  27. <el-dialog width="600px" title="选择类别" :visible.sync="categoryVisible">
  28. <category-select ref="categorySelect"></category-select>
  29. <span slot="footer" class="dialog-footer">
  30. <el-button @click="categoryVisible = false">{{ $t('common.cancel') }}</el-button>
  31. <el-button type="primary" @click="categoryChanged">{{ $t('common.sure') }}</el-button>
  32. </span>
  33. </el-dialog>
  34. <el-dialog title="选择商品" :visible.sync="productVisible">
  35. <product-select ref="productSelect"></product-select>
  36. <span slot="footer" class="dialog-footer">
  37. <el-button @click="productVisible = false">{{ $t('common.cancel') }}</el-button>
  38. <el-button type="primary" @click="productChanged">{{ $t('common.sure') }}</el-button>
  39. </span>
  40. </el-dialog>
  41. <el-dialog title="选择互动图" :visible.sync="interactiondiagramVisible">
  42. <interactiondiagram-select ref="interactiondiagramSelect"></interactiondiagram-select>
  43. <span slot="footer" class="dialog-footer">
  44. <el-button @click="interactiondiagramVisible = false">{{ $t('common.cancel') }}</el-button>
  45. <el-button type="primary" @click="interactiondiagramChanged">{{ $t('common.sure') }}</el-button>
  46. </span>
  47. </el-dialog>
  48. <el-dialog title="选择店辅" :visible.sync="shopVisible">
  49. <shop-select ref="shopSelect"></shop-select>
  50. <span slot="footer" class="dialog-footer">
  51. <el-button @click="shopVisible = false">{{ $t('common.cancel') }}</el-button>
  52. <el-button type="primary" @click="shopChanged">{{ $t('common.sure') }}</el-button>
  53. </span>
  54. </el-dialog>
  55. <el-dialog title="选择自定义页面" :visible.sync="customVisible">
  56. <custom-page-select ref="customPageSelect"></custom-page-select>
  57. <span slot="footer" class="dialog-footer">
  58. <el-button @click="customVisible = false">{{ $t('common.cancel') }}</el-button>
  59. <el-button type="primary" @click="customChanged">{{ $t('common.sure') }}</el-button>
  60. </span>
  61. </el-dialog>
  62. <el-dialog title="选择公告" :visible.sync="noticeVisible">
  63. <notice-select ref="noticeSelect"></notice-select>
  64. <span slot="footer" class="dialog-footer">
  65. <el-button @click="noticeVisible = false">{{ $t('common.cancel') }}</el-button>
  66. <el-button type="primary" @click="noticeChanged">{{ $t('common.sure') }}</el-button>
  67. </span>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import ProductSelect from './product-select'
  73. import InteractiondiagramSelect from './interactiondiagram-select'
  74. import ShopSelect from './shop-select'
  75. import CategorySelect from './category-select'
  76. import CustomPageSelect from './custom-page-select'
  77. import NoticeSelect from "./notice-select";
  78. export default {
  79. name: 'tool-select-link',
  80. components: {NoticeSelect, CustomPageSelect, CategorySelect, ShopSelect, ProductSelect, InteractiondiagramSelect },
  81. data () {
  82. return {
  83. selsectValue: '',
  84. confirmBtnVisible: false,
  85. selectName: '',
  86. typeText: '',
  87. productVisible: false,
  88. interactiondiagramVisible: false,
  89. shopVisible: false,
  90. categoryVisible: false,
  91. customVisible: false,
  92. noticeVisible: false
  93. }
  94. },
  95. props: {
  96. title: {
  97. type: String,
  98. default: '链接'
  99. },
  100. styleType: {
  101. type: String,
  102. default: ''
  103. },
  104. linkObj: {
  105. type: Object,
  106. default: () => ({
  107. selsectValue: '',
  108. selectName: '',
  109. typeText: '',
  110. url: ''
  111. })
  112. },
  113. options: {
  114. type: Array,
  115. default: () => [
  116. // {
  117. // value: '/index',
  118. // label: '首页'
  119. // },
  120. {
  121. value: '/category',
  122. label: '分类页面'
  123. },
  124. {
  125. value: '/shop',
  126. label: '店辅主页'
  127. },
  128. {
  129. value: '/detail',
  130. label: '商品详情'
  131. },
  132. {
  133. value: '/interactiondiagramdetail',
  134. label: '互动图详情'
  135. },
  136. {
  137. value: '/notice',
  138. label: '公告'
  139. },
  140. // {
  141. // value: '/custom',
  142. // label: '自定义页面'
  143. // }
  144. ]
  145. }
  146. },
  147. mounted () {
  148. this.selsectValue = this.linkObj.selsectValue
  149. this.selectName = this.linkObj.selectName
  150. this.typeText = this.linkObj.typeText
  151. this.confirmBtnVisible = this.selsectValue !== '/index' && this.selsectValue
  152. },
  153. methods: {
  154. // 链接选择
  155. selectChanged (value) {
  156. this.categoryVisible = false
  157. this.shopVisible = false
  158. this.productVisible = false
  159. this.confirmBtnVisible = true
  160. this.interactiondiagramVisible = false
  161. this.selectName = ''
  162. this.typeText = ''
  163. switch (value) {
  164. case '/category':
  165. this.typeText = '类别'
  166. break
  167. case '/shop':
  168. this.typeText = '店辅'
  169. break
  170. case '/detail':
  171. this.typeText = '商品'
  172. break
  173. case '/interactiondiagramdetail':
  174. this.typeText = '互动图'
  175. break
  176. case '/custom':
  177. this.typeText = '自定义'
  178. case '/notice':
  179. this.typeText = '公告'
  180. break
  181. default:
  182. this.confirmBtnVisible = false
  183. let linkObj = {
  184. selsectValue: this.selsectValue,
  185. selectName: '',
  186. typeText: '',
  187. url: '/'
  188. }
  189. this.$emit('update:linkObj', linkObj)
  190. }
  191. },
  192. // 打开添加弹窗
  193. openDialog () {
  194. switch (this.typeText) {
  195. case '类别':
  196. this.categoryVisible = true
  197. break
  198. case '店辅':
  199. this.shopVisible = true
  200. break
  201. case '商品':
  202. this.productVisible = true
  203. break
  204. case '互动图':
  205. this.interactiondiagramVisible = true
  206. break
  207. case '自定义':
  208. this.customVisible = true
  209. case '公告':
  210. this.noticeVisible = true
  211. break
  212. }
  213. },
  214. // 类别选择
  215. categoryChanged () {
  216. let nodesObj = this.$refs.categorySelect.$refs['cascader'].getCheckedNodes()
  217. if (nodesObj) {
  218. var data = nodesObj[0].data
  219. this.selectName = nodesObj[0].label
  220. this.categoryVisible = false
  221. let linkObj = {
  222. selsectValue: this.selsectValue,
  223. selectName: this.selectName,
  224. typeText: this.typeText,
  225. data: data
  226. }
  227. this.$emit('update:linkObj', linkObj)
  228. }
  229. },
  230. // 商品选择
  231. productChanged () {
  232. console.log(this.$refs.productSelect)
  233. var data = this.$refs.productSelect.tableRadio
  234. this.productVisible = false
  235. this.selectName = this.$refs.productSelect.tableRadio.productName
  236. let linkObj = {
  237. selsectValue: this.selsectValue,
  238. selectName: this.selectName,
  239. typeText: this.typeText,
  240. data: data
  241. }
  242. this.$emit('update:linkObj', linkObj)
  243. },
  244. // 互动图选择
  245. interactiondiagramChanged () {
  246. console.log(this.$refs.interactiondiagramSelect)
  247. var data = this.$refs.interactiondiagramSelect.tableRadio
  248. this.interactiondiagramVisible = false
  249. this.selectName = this.$refs.interactiondiagramSelect.tableRadio.interactionDiagramName
  250. let linkObj = {
  251. selsectValue: this.selsectValue,
  252. selectName: this.selectName,
  253. typeText: this.typeText,
  254. data: data
  255. }
  256. this.$emit('update:linkObj', linkObj)
  257. },
  258. // 店辅选择
  259. shopChanged () {
  260. var data = this.$refs.shopSelect.tableRadio
  261. this.shopVisible = false
  262. this.selectName = this.$refs.shopSelect.tableRadio.shopName
  263. let linkObj = {
  264. selsectValue: this.selsectValue,
  265. selectName: this.selectName,
  266. typeText: this.typeText,
  267. data: data
  268. }
  269. this.$emit('update:linkObj', linkObj)
  270. },
  271. // 自定义页面选择
  272. customChanged () {
  273. var data = this.$refs.customPageSelect.tableRadio
  274. this.customVisible = false
  275. this.selectName = this.$refs.customPageSelect.tableRadio.name
  276. let linkObj = {
  277. selsectValue: this.selsectValue,
  278. selectName: this.selectName,
  279. typeText: this.typeText,
  280. data: data
  281. }
  282. this.$emit('update:linkObj', linkObj)
  283. },
  284. // 公告选择
  285. noticeChanged () {
  286. var data = this.$refs.noticeSelect.tableRadio
  287. this.noticeVisible = false
  288. this.selectName = this.$refs.noticeSelect.tableRadio.noticeTitle
  289. let linkObj = {
  290. selsectValue: this.selsectValue,
  291. selectName: this.selectName,
  292. typeText: this.typeText,
  293. data: data
  294. }
  295. this.$emit('update:linkObj', linkObj)
  296. },
  297. // 删除选择
  298. delSelect () {
  299. let linkObj = {
  300. selsectValue: '',
  301. selectName: '',
  302. typeText: '',
  303. data: {}
  304. }
  305. this.$emit('update:linkObj', linkObj)
  306. }
  307. },
  308. watch: {
  309. linkObj: {
  310. handler (newVal, oldVal) {
  311. this.selsectValue = newVal.selsectValue
  312. this.selectName = newVal.selectName
  313. this.typeText = newVal.typeText
  314. this.confirmBtnVisible = this.selsectValue !== '/index' && this.selsectValue
  315. },
  316. deep: true
  317. }
  318. }
  319. }
  320. </script>
  321. <style lang="scss" scoped>
  322. .link-select{
  323. &__select{
  324. width: 100%;
  325. }
  326. &__confirm{
  327. margin-top: 10px;
  328. .btn{
  329. text-align: center;
  330. background-color: $mainColor;
  331. color: #fff;
  332. height: 36px;
  333. line-height: 36px;
  334. border-radius: 4px;
  335. cursor: pointer;
  336. }
  337. .info{
  338. height: 36px;
  339. line-height: 36px;
  340. border-radius: 4px;
  341. padding: 0 10px;
  342. border:1px solid $mainColor;
  343. display: flex;
  344. .text{
  345. color: $mainColor;
  346. }
  347. .name{
  348. flex: 1;
  349. margin-left: 10px;
  350. overflow: hidden;
  351. text-overflow:ellipsis;
  352. white-space: nowrap;
  353. }
  354. .iconfont{
  355. margin-left: 10px;
  356. cursor: pointer;
  357. color: #666;
  358. }
  359. }
  360. }
  361. &.style1{
  362. .link-select__warp{
  363. display: flex;
  364. justify-content: space-between;
  365. width: 100%;
  366. align-items: center;
  367. }
  368. width: 100%;
  369. margin-bottom: 0;
  370. .module-box__title{
  371. margin-bottom: 0;
  372. }
  373. .link-select__select{
  374. width: auto;
  375. }
  376. }
  377. }
  378. </style>