store.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <!--
  2. * @Descripttion: 用户选择器
  3. * @version: 1.0
  4. * @Author: Zory
  5. * @Date: 2024年1月10日21:46:29
  6. -->
  7. <template>
  8. <el-dialog :title="titleMap[mode]" v-model="visible" :width="800" destroy-on-close @closed="$emit('closed')">
  9. <div class="main">
  10. <div class="main-left">
  11. <div class="main-top">
  12. <el-form class="lv-form-inline" ref="searchForm" :model="searchKey" label-position="right">
  13. <el-row :gutter="10">
  14. <el-col :span="18" :xs="12">
  15. <el-form-item label=" " prop="name">
  16. <el-input v-model="searchKey.name" placeholder="请输入门店名称" clearable
  17. :style="{width: '100%'}"></el-input>
  18. </el-form-item>
  19. </el-col>
  20. <el-col :span="6" :xs="12">
  21. <el-form-item>
  22. <div class="search-btn">
  23. <el-button type="primary" @click="searchForm">搜索</el-button>
  24. </div>
  25. </el-form-item>
  26. </el-col>
  27. </el-row>
  28. </el-form>
  29. </div>
  30. <div class="main-body-wrap" v-if="!multiple">
  31. <scTable ref="table" :apiObj="list.apiObj" :hideSetting="true" paginationLayout="total, prev, pager, next" :params="searchKey" @current-change="handleCurrentChange" highlight-current-row :row-key="getRowKeys" @sortChange="sortChange">
  32. <el-table-column width="50" fixed="left">
  33. <div class="checkbox"></div>
  34. </el-table-column>
  35. <el-table-column label="店铺名称" width="200" fixed="left" prop="shop_name"></el-table-column>
  36. <el-table-column label="店铺编码" prop="shop_id" width="200"></el-table-column>
  37. <el-table-column label="营业时间" prop="agent" width="150">
  38. <template #default="scope">
  39. <span v-if="scope.row.start_at">{{ scope.row.start_at }}-{{ scope.row.end_at }}</span>
  40. <span class="status-danger" v-else>未设置</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column label="到期时间" prop="vip_end" width="180">
  44. <template #default="scope">
  45. <span v-if="scope.row.vip_end">{{ scope.row.vip_end }}</span>
  46. <span class="status-danger" v-else>未设置</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="收费规则" prop="rate_type" width="150">
  50. <template #default="scope">
  51. <div class="status-success" v-if="scope.row.rate_type==1"><sc-status-indicator type="success"></sc-status-indicator> 收取年费</div>
  52. <div class="status-danger" v-if="scope.row.rate_type==2"><sc-status-indicator type="danger"></sc-status-indicator> 订单金额抽佣</div>
  53. <div class="status-danger" v-if="scope.row.rate_type==0"><sc-status-indicator type="danger"></sc-status-indicator> 未设置</div>
  54. </template>
  55. </el-table-column>
  56. <el-table-column label="联系人" prop="shop_contact" width="150">
  57. <template #default="scope">
  58. <span v-if="scope.row.shop_contact">{{ scope.row.shop_contact }}</span>
  59. <span class="status-danger" v-else>未设置</span>
  60. </template>
  61. </el-table-column>
  62. <el-table-column label="联系电话" prop="shop_mobile" width="150">
  63. <template #default="scope">
  64. <span v-if="scope.row.shop_mobile">{{ scope.row.shop_mobile }}</span>
  65. <span class="status-danger" v-else>未设置</span>
  66. </template>
  67. </el-table-column>
  68. <el-table-column label="店铺地址" prop="shop_address" width="300">
  69. <template #default="scope">
  70. <span v-if="scope.row.shop_address">{{ scope.row.shop_address }}</span>
  71. <span class="status-danger" v-else>未设置</span>
  72. </template>
  73. </el-table-column>
  74. <el-table-column label="状态" prop="status" width="120" align="center">
  75. <template #default="scope">
  76. <div class="status-success" v-if="scope.row.status==0"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  77. <div class="status-danger" v-if="scope.row.status==1"><sc-status-indicator type="danger"></sc-status-indicator> 已到期</div>
  78. <div class="status-danger" v-if="scope.row.status==2"><sc-status-indicator type="danger"></sc-status-indicator> 关店</div>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
  82. </scTable>
  83. </div>
  84. <div class="main-body-wrap" v-else>
  85. <scTable ref="table" :apiObj="list.apiObj" :hideSetting="true" paginationLayout="total, prev, pager, next" :params="searchKey" @selectionChange="selectionChange" row-key="id" @sortChange="sortChange">
  86. <el-table-column type="selection" width="50" fixed="left"></el-table-column>
  87. <el-table-column label="店铺编码" prop="shop_id" width="200"></el-table-column>
  88. <el-table-column label="营业时间" prop="agent" width="150">
  89. <template #default="scope">
  90. <span v-if="scope.row.start_at">{{ scope.row.start_at }}-{{ scope.row.end_at }}</span>
  91. <span class="status-danger" v-else>未设置</span>
  92. </template>
  93. </el-table-column>
  94. <el-table-column label="到期时间" prop="vip_end" width="180">
  95. <template #default="scope">
  96. <span v-if="scope.row.vip_end">{{ scope.row.vip_end }}</span>
  97. <span class="status-danger" v-else>未设置</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column label="收费规则" prop="rate_type" width="150">
  101. <template #default="scope">
  102. <div class="status-success" v-if="scope.row.rate_type==1"><sc-status-indicator type="success"></sc-status-indicator> 收取年费</div>
  103. <div class="status-danger" v-if="scope.row.rate_type==2"><sc-status-indicator type="danger"></sc-status-indicator> 订单金额抽佣</div>
  104. <div class="status-danger" v-if="scope.row.rate_type==0"><sc-status-indicator type="danger"></sc-status-indicator> 未设置</div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column label="联系人" prop="shop_contact" width="150">
  108. <template #default="scope">
  109. <span v-if="scope.row.shop_contact">{{ scope.row.shop_contact }}</span>
  110. <span class="status-danger" v-else>未设置</span>
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="联系电话" prop="shop_mobile" width="150">
  114. <template #default="scope">
  115. <span v-if="scope.row.shop_mobile">{{ scope.row.shop_mobile }}</span>
  116. <span class="status-danger" v-else>未设置</span>
  117. </template>
  118. </el-table-column>
  119. <el-table-column label="店铺地址" prop="shop_address" width="300">
  120. <template #default="scope">
  121. <span v-if="scope.row.shop_address">{{ scope.row.shop_address }}</span>
  122. <span class="status-danger" v-else>未设置</span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column label="状态" prop="status" width="120" align="center">
  126. <template #default="scope">
  127. <div class="status-success" v-if="scope.row.status==0"><sc-status-indicator type="success"></sc-status-indicator> 正常</div>
  128. <div class="status-danger" v-if="scope.row.status==1"><sc-status-indicator type="danger"></sc-status-indicator> 已到期</div>
  129. <div class="status-danger" v-if="scope.row.status==2"><sc-status-indicator type="danger"></sc-status-indicator> 关店</div>
  130. </template>
  131. </el-table-column>
  132. <el-table-column label="创建时间" prop="create_at" width="180"></el-table-column>
  133. </scTable>
  134. </div>
  135. </div>
  136. </div>
  137. <template #footer>
  138. <el-button @click="visible=false" >取 消</el-button>
  139. <el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">确 定</el-button>
  140. </template>
  141. </el-dialog>
  142. </template>
  143. <script>
  144. export default{
  145. emits: ['success', 'closed'],
  146. props: {
  147. multiple: { type: Boolean, default: false },
  148. },
  149. data(){
  150. return {
  151. loading: false,
  152. mode:"add",
  153. titleMap:{
  154. add:"选择店铺",
  155. edit:"选择店铺"
  156. },
  157. list: {
  158. apiObj: this.$API.shop.list
  159. },
  160. visible: false,
  161. isSaveing: false,
  162. formData:{},
  163. searchKey:{},
  164. selectData:[]
  165. }
  166. },
  167. methods:{
  168. sortChange(event){
  169. if (event.order) {
  170. var data = {
  171. "field":event.prop,
  172. "order":event.order
  173. }
  174. this.$refs.table.upData(data)
  175. } else {
  176. this.$refs.table.reload(this.searchKey)
  177. }
  178. return ;
  179. },
  180. submit(){
  181. if (this.selectData.length == 0)
  182. {
  183. return this.$message.error("请选择数据");
  184. }
  185. this.isSaveing = false;
  186. this.visible = false;
  187. if (this.multiple){
  188. this.$emit('success', this.selectData);
  189. } else {
  190. this.$emit('success', this.selectData[0]);
  191. }
  192. },
  193. getRowKeys(data){
  194. return data.id;
  195. },
  196. clearAll(){
  197. this.selectData = [];
  198. },
  199. removeUser(index,name){
  200. this.selectData.splice(index, 1);
  201. console.log(name)
  202. },
  203. handleCurrentChange(data){
  204. this.selectData = [data];
  205. },
  206. selectionChange(data){
  207. this.selectData = data;
  208. },
  209. searchForm(){
  210. this.$refs.table.upData(this.searchKey)
  211. },
  212. fristName(name){
  213. return name.substring(0,1);
  214. },
  215. open(mode = 'add'){
  216. this.mode = mode;
  217. this.visible = true;
  218. return this
  219. },
  220. //表单注入数据
  221. setData(data){
  222. this.formData = data;
  223. },
  224. }
  225. }
  226. </script>
  227. <style lang="scss" scoped>
  228. .main{
  229. display: flex;
  230. border: 1px solid #dfe1e6;
  231. }
  232. .main-left{
  233. overflow: hidden;
  234. flex: 1;
  235. .main-body-wrap{
  236. position: relative;
  237. height: 380px;
  238. }
  239. }
  240. .main-top{
  241. position: relative;
  242. padding: 10px 0;
  243. border-bottom: 1px solid #dfe1e6;
  244. &.is-right{
  245. height:53px;
  246. display:flex;
  247. align-items:center;
  248. padding:0 10px;
  249. justify-content:space-between;
  250. }
  251. }
  252. .main-body.is-right{
  253. padding: 8px 16px;
  254. overflow-y: auto;
  255. position: relative;
  256. height: calc(100% - 53px);
  257. max-height: 380px;
  258. }
  259. .mx-1{
  260. margin: 0 0.5rem 0.5rem 0;
  261. }
  262. .main-right{
  263. flex: 0.4;
  264. }
  265. .el-form-item--default{
  266. margin-bottom: 0;
  267. }
  268. .checkbox{
  269. border:1px solid #dfe1e6;
  270. width: 14px;
  271. height: 14px;
  272. border-radius: 2px;
  273. background-color: #fff;
  274. cursor: pointer;
  275. position:relative
  276. }
  277. .current-row .checkbox{
  278. background-color: var(--el-color-primary);
  279. border-color: var(--el-color-primary);
  280. }
  281. .current-row .checkbox:after{
  282. transform: rotate(45deg) scaleY(1);
  283. box-sizing: content-box;
  284. content: "";
  285. border: 1px solid #fff;
  286. border-left: 0;
  287. border-top: 0;
  288. height: 7px;
  289. left: 4px;
  290. position: absolute;
  291. top: 1px;
  292. width: 3px;
  293. transition: transform .15s ease-in 50ms;
  294. transform-origin: center;
  295. }
  296. </style>