SelectShortLink.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div>
  3. <el-dialog :title="title" :visible.sync="Pvisible" width="800px" append-to-body :close-on-click-modal="false">
  4. <template v-if="list.length || !isInit">
  5. <el-row type="flex" justify="space-between" style="max-height: 500px;">
  6. <el-col style="margin-top: 0px;">
  7. <div>
  8. <el-form ref="queryForm" :model="query" :inline="true" label-width="">
  9. <el-form-item label="短链名称" prop="shortLinkName">
  10. <el-input clearable v-model="query.shortLinkName" placeholder="请输入"></el-input>
  11. </el-form-item>
  12. <el-form-item label="类型" prop="type">
  13. <el-select clearable v-model="query.type" placeholder="请选择">
  14. <el-option
  15. v-for="(item, index) in touchTypeDict"
  16. :key="index"
  17. :label="item.allName"
  18. :value="+index"
  19. ></el-option>
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="">
  23. <el-button type="primary" @click="search()">查询</el-button>
  24. <el-button @click="resetForm()">重置</el-button>
  25. </el-form-item>
  26. </el-form>
  27. <el-table :data="list" v-loading="loading">
  28. <el-table-column width="30">
  29. <template slot-scope="{ row }">
  30. <el-radio v-model="radio" :label="row"></el-radio>
  31. </template>
  32. </el-table-column>
  33. <el-table-column label="短链名称" align="center" prop="shortLinkName" show-overflow-tooltip />
  34. <el-table-column label="类型" align="center" prop="type">
  35. <template slot-scope="{ row }">{{ touchTypeDict[row.type + ''].allName }}</template>
  36. </el-table-column>
  37. <el-table-column label="短链地址" align="center" prop="shortLink" show-overflow-tooltip>
  38. <template slot-scope="{ row }">
  39. <span>{{ row.shortLink }}</span>
  40. <i
  41. class="el-icon-copy-document copy-btn cp ml20"
  42. title="复制"
  43. :data-clipboard-text="row.shortLink"
  44. ></i>
  45. </template>
  46. </el-table-column>
  47. <el-table-column label="最近更新时间" align="center" prop="updateTime" width="180"></el-table-column>
  48. </el-table>
  49. <pagination
  50. v-show="total > 0"
  51. :total="total"
  52. :page.sync="query.pageNum"
  53. :limit.sync="query.pageSize"
  54. @pagination="getList()"
  55. />
  56. </div>
  57. </el-col>
  58. </el-row>
  59. <div slot="footer" style="padding: 10px 0;">
  60. <el-button @click="Pvisible = false">取 消</el-button>
  61. <el-button type="primary" @click="submit">确 定</el-button>
  62. </div>
  63. </template>
  64. <template v-if="!list.length && isInit">
  65. <div class="empty">
  66. <div>
  67. 暂无短链,点击下方按钮立即创建
  68. <div style="margin-top: 30px;">
  69. <el-button
  70. size="mini"
  71. type="primary"
  72. @click="$router.push('/drainageCode/publicCustomer/IntelligentShortLink/index')"
  73. >
  74. 去新建
  75. </el-button>
  76. </div>
  77. </div>
  78. </div>
  79. </template>
  80. </el-dialog>
  81. </div>
  82. </template>
  83. <script>
  84. import { getList } from '@/api/intelligentShortLink'
  85. import { touchTypeDict } from '@/views/intelligentShortLink/components/mixin'
  86. export default {
  87. components: {},
  88. props: {
  89. //显隐
  90. visible: {
  91. type: Boolean,
  92. default: false
  93. },
  94. title: {
  95. type: String,
  96. default: '选择短链'
  97. },
  98. selected: {
  99. type: Array,
  100. default: () => []
  101. }
  102. },
  103. data() {
  104. return {
  105. isInit: true,
  106. touchTypeDict,
  107. loading: true, // 遮罩层
  108. query: {
  109. pageNum: 1,
  110. pageSize: 10,
  111. type: null,
  112. shortLinkName: ''
  113. },
  114. list: [], // 列表
  115. total: 0, // 总条数
  116. radio: '',
  117. dialogVisible: false
  118. }
  119. },
  120. watch: {
  121. selected(val) {
  122. this.setSelected()
  123. },
  124. list(val) {
  125. this.setSelected()
  126. }
  127. },
  128. computed: {
  129. Pvisible: {
  130. get() {
  131. return this.visible
  132. },
  133. set(val) {
  134. this.$emit('update:visible', val)
  135. }
  136. }
  137. },
  138. created() {
  139. this.getList()
  140. },
  141. mounted() {},
  142. methods: {
  143. resetForm() {
  144. this.$refs['queryForm'].resetFields()
  145. this.isInit = true
  146. this.getList(1)
  147. },
  148. search() {
  149. this.isInit = false
  150. this.query.pageNum = 1
  151. this.getList()
  152. },
  153. // 获取列表
  154. getList(page) {
  155. page && (this.query.pageNum = page)
  156. this.loading = true
  157. getList(this.query)
  158. .then(({ rows, total }) => {
  159. this.radio = ''
  160. this.list = rows ? rows : []
  161. this.total = +total
  162. this.loading = false
  163. })
  164. .catch(() => {
  165. this.loading = false
  166. })
  167. },
  168. submit() {
  169. if (!this.radio) {
  170. this.msgError('请选择一项!')
  171. return
  172. }
  173. this.Pvisible = false
  174. this.$emit('success', this.radio)
  175. },
  176. setSelected() {
  177. if (!this.selected.length) return
  178. this.list.forEach((code) => {
  179. if (code.id == this.selected[0].id) {
  180. this.radio = code
  181. }
  182. })
  183. }
  184. }
  185. }
  186. </script>
  187. <style lang="scss" scoped>
  188. .empty {
  189. height: 300px;
  190. text-align: center;
  191. display: flex;
  192. flex-direction: column;
  193. justify-content: space-around;
  194. }
  195. .code-image {
  196. width: 200px;
  197. height: 200px;
  198. }
  199. .code-image--small {
  200. width: 50px;
  201. height: 50px;
  202. }
  203. .expire-icon {
  204. color: red;
  205. }
  206. .left {
  207. margin-right: 16px;
  208. .title {
  209. color: var(--color);
  210. display: flex;
  211. justify-content: space-between;
  212. align-items: center;
  213. .title-name {
  214. color: rgba(0, 0, 0, 0.9);
  215. font-size: 16px;
  216. font-weight: 600;
  217. // color: #333333;
  218. display: flex;
  219. align-items: center;
  220. }
  221. .title-btn {
  222. cursor: pointer;
  223. display: flex;
  224. align-items: center;
  225. font-size: 14px;
  226. font-weight: normal;
  227. color: var(--color);
  228. &:hover {
  229. opacity: 0.8;
  230. }
  231. }
  232. }
  233. .item-list {
  234. max-height: 700px;
  235. padding-top: 15px;
  236. display: flex;
  237. flex-direction: column;
  238. height: 100%;
  239. overflow-x: hidden;
  240. overflow-y: auto;
  241. .item {
  242. cursor: pointer;
  243. display: flex;
  244. justify-content: space-between;
  245. align-items: center;
  246. font-size: 14px;
  247. color: rgba(0, 0, 0, 0.6);
  248. height: 40px;
  249. line-height: 40px;
  250. width: 100%;
  251. padding-left: 20px;
  252. .name {
  253. overflow: hidden;
  254. white-space: nowrap;
  255. text-overflow: ellipsis;
  256. }
  257. .dropdown {
  258. // display: none;
  259. .dot {
  260. cursor: pointer;
  261. width: 15px;
  262. height: 15px;
  263. line-height: 15px;
  264. font-size: 14px;
  265. font-family: JMT-Font, JMT;
  266. font-weight: normal;
  267. color: rgba(0, 0, 0, 0.6);
  268. margin-right: 10px;
  269. margin-left: 5px;
  270. font-weight: 500;
  271. .content-icon {
  272. color: rgba(0, 0, 0, 0.6);
  273. font-size: 12px;
  274. transform: rotate(90deg);
  275. }
  276. }
  277. }
  278. &:hover {
  279. color: rgba(0, 0, 0, 0.9);
  280. background: #f5f8fe;
  281. opacity: 0.8;
  282. border-radius: 2px;
  283. .dropdown {
  284. // display: block;
  285. }
  286. }
  287. }
  288. .active {
  289. // border-left: 2px solid var(--color);
  290. color: rgba(0, 0, 0, 0.9);
  291. background: #f5f8fe;
  292. border-radius: 2px;
  293. }
  294. }
  295. }
  296. </style>