shop.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <script setup lang='ts'>
  2. import { onMounted, reactive, ref } from 'vue'
  3. import { shopList, deleteShop, getShopList } from '@/api'
  4. import { message } from 'ant-design-vue';
  5. let shopListSearch = reactive({ arr: [{ id: 0, name: '' }] })
  6. interface FormState {
  7. cityName: string;
  8. shopId?: Number;
  9. mobile?: number;
  10. }
  11. const formState = reactive<FormState>({
  12. cityName: '',
  13. });
  14. const columns = reactive([
  15. {
  16. title: '门店编号',
  17. dataIndex: 'code',
  18. align: 'center',
  19. },
  20. {
  21. title: '店铺名称',
  22. dataIndex: 'name',
  23. align: 'center',
  24. },
  25. {
  26. title: '联系人',
  27. dataIndex: 'contactName',
  28. align: 'center',
  29. },
  30. {
  31. title: '联系电话',
  32. dataIndex: 'mobile',
  33. align: 'center',
  34. },
  35. {
  36. title: '城市',
  37. dataIndex: 'cityName',
  38. align: 'center',
  39. },
  40. {
  41. title: '地址',
  42. dataIndex: 'address',
  43. align: 'center',
  44. },
  45. {
  46. title: '已获运力',
  47. dataIndex: 'deliveries',
  48. width: '25%',
  49. align: 'center',
  50. },
  51. {
  52. title: '操作',
  53. dataIndex: 'operation',
  54. fixed: 'right',
  55. width: '10%',
  56. align: 'center',
  57. }
  58. ])
  59. const data = reactive({ arr: [] })
  60. const handleShopList = () => {
  61. shopList(formState).then((res: any) => {
  62. console.log('res', res);
  63. if (res.code) {
  64. data.arr = res.data
  65. } else {
  66. message.error(res.msg)
  67. }
  68. })
  69. }
  70. handleShopList()
  71. const handleGetShopList = () => {
  72. getShopList().then((res: any) => {
  73. console.log('res', res);
  74. if (res.code) {
  75. shopListSearch.arr = res.data
  76. } else {
  77. message.error(res.msg)
  78. }
  79. })
  80. }
  81. handleGetShopList()
  82. const onDelete = (shopId: number) => {
  83. deleteShop({ shopId }).then((res: any) => {
  84. if (res.code === 200) {
  85. message.success('已经成功删除!')
  86. handleShopList()
  87. } else {
  88. message.error(res.msg)
  89. }
  90. })
  91. }
  92. onMounted(() => {
  93. })
  94. </script>
  95. <template>
  96. <div class="text-20px text-[#222222] font-bold mb-30px">店铺管理</div>
  97. <a-form :model="formState" name="horizontal_login" layout="inline" autocomplete="off" class="mb-20px">
  98. <a-form-item label="城市" name="cityName">
  99. <a-input v-model:value="formState.cityName" placeholder="请输入要查询的城市">
  100. </a-input>
  101. </a-form-item>
  102. <a-form-item label="店铺名称" name="name">
  103. <a-select v-model:value="formState.shopId" style="width: 200px" placeholder="请选择要查询的店铺名称" allowClear>
  104. <a-select-option v-for="(v, i) in shopListSearch.arr" :key="i" :value="v.id">{{ v.name }}</a-select-option>
  105. </a-select>
  106. </a-form-item>
  107. <a-form-item label="联系人电话" name="mobile">
  108. <a-input v-model:value="formState.mobile" placeholder="请输入要查询的联系人电话">
  109. </a-input>
  110. </a-form-item>
  111. <a-form-item>
  112. <a-button class="ml-20px" type="primary" @click="handleShopList">查 询</a-button>
  113. <!-- <a-button class="ml-20px" type="primary" ghost html-type="submit">导 出</a-button> -->
  114. <a-button class="ml-20px" type="primary" ghost html-type="submit">+新建门店</a-button>
  115. </a-form-item>
  116. </a-form>
  117. <a-table :columns="columns" :data-source="data.arr" :pagination="false" bordered :scroll="true">
  118. <template #bodyCell="{ column, text, record }">
  119. <template v-if="column.dataIndex === 'deliveries'">
  120. <div class="flex flex-wrap justify-center">
  121. <img :src="v.logo" alt="" v-for="(v, i) in text" :key="i" class="w-20px h-20px mr-10px">
  122. </div>
  123. </template>
  124. <template v-if="column.dataIndex === 'operation'">
  125. <a class="text-blue-500">编辑</a>
  126. <a-popconfirm v-if="data.arr.length" title="确定删除该店铺?" ok-text="确定" cancel-text="取消" @confirm="onDelete(record.id)">
  127. <a class="text-blue-500 ml-20px">删除</a>
  128. </a-popconfirm>
  129. </template>
  130. </template>
  131. </a-table>
  132. </template>
  133. <style lang='scss' scoped>
  134. </style>