index.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <script setup lang="tsx">
  2. import { ref, useTemplateRef } from 'vue';
  3. import { NButton } from 'naive-ui';
  4. import { router } from '@/router';
  5. import { fetchGetChannelList, fetchImportGoods } from '@/service/api/goods-center/store-goods';
  6. import { fetchMoivecinemaList, fetchMovieList } from '@/service/api/film-manage/film-list';
  7. import { useTable } from '@/components/zt/Table/hooks/useTable';
  8. const importTemplateRef = useTemplateRef('importTemplateRef');
  9. const options = ref<Api.goods.Channel[]>([]);
  10. const statusList = ['上架', '可售', '下架', '即将上映'];
  11. const columns: NaiveUI.TableColumn<Api.goods.ShopSku>[] = [
  12. {
  13. type: 'selection',
  14. align: 'center',
  15. width: 48,
  16. fixed: 'left'
  17. },
  18. {
  19. key: 'supId',
  20. title: '商品ID',
  21. align: 'left',
  22. width: 200,
  23. render: (row: any) => {
  24. return (
  25. <div class={'flex items-center'}>
  26. <div>统一ID:</div>
  27. <div>{row.movieId}</div>
  28. </div>
  29. );
  30. }
  31. },
  32. {
  33. key: 'pic',
  34. title: '商品图片',
  35. align: 'center',
  36. width: 120,
  37. render: (row: any) => {
  38. return <n-image src={row.posterUrl} width={60} height={60}></n-image>;
  39. }
  40. },
  41. {
  42. key: 'movieName',
  43. title: '商品名称',
  44. align: 'center',
  45. width: 120,
  46. ellipsis: {
  47. tooltip: true
  48. }
  49. },
  50. {
  51. key: 'businessType',
  52. title: '业务类型',
  53. align: 'center',
  54. width: 120,
  55. ellipsis: {
  56. tooltip: true
  57. }
  58. },
  59. {
  60. key: 'cinemaName',
  61. title: '商户',
  62. align: 'center',
  63. width: 120,
  64. ellipsis: {
  65. tooltip: true
  66. }
  67. },
  68. {
  69. key: 'channelVOS',
  70. title: '价格',
  71. align: 'center',
  72. width: 120,
  73. render: (row: any) => {
  74. return (
  75. <div>
  76. {row.moviePriceVo.map((it: Api.government.ChannelVO) => {
  77. return (
  78. <div>
  79. {it.channl}:¥{it.price}
  80. </div>
  81. );
  82. })}
  83. </div>
  84. );
  85. }
  86. },
  87. {
  88. key: 'status',
  89. title: '状态',
  90. align: 'center',
  91. width: 120,
  92. render: (row: any) => {
  93. return (
  94. <div class="flex items-center justify-center">
  95. <n-badge color={row.status == 0 ? 'green' : 'red'} value={row.status} dot />
  96. <span class="ml-2">{statusList[row.status]}</span>
  97. </div>
  98. );
  99. }
  100. },
  101. {
  102. key: 'updateTime',
  103. title: '更新时间',
  104. align: 'center',
  105. width: 120,
  106. ellipsis: {
  107. tooltip: true
  108. }
  109. }
  110. ];
  111. const [registerTable] = useTable({
  112. searchFormConfig: {
  113. schemas: [
  114. {
  115. label: '商户',
  116. component: 'ApiSelect',
  117. field: 'cinemaName',
  118. componentProps: {
  119. api: fetchMoivecinemaList,
  120. labelFeild: 'name',
  121. valueFeild: 'name'
  122. }
  123. },
  124. {
  125. label: '关键词',
  126. component: 'NInput',
  127. field: 'keywords'
  128. },
  129. {
  130. label: '状态',
  131. field: 'status',
  132. component: 'NSelect',
  133. componentProps: {
  134. options: [
  135. {
  136. label: '上架',
  137. value: 0
  138. },
  139. {
  140. label: '可售',
  141. value: 1
  142. },
  143. {
  144. label: '下架',
  145. value: 2
  146. },
  147. {
  148. label: '即将上映',
  149. value: 3
  150. }
  151. ]
  152. }
  153. }
  154. ],
  155. inline: false,
  156. size: 'small',
  157. labelPlacement: 'left',
  158. isFull: false
  159. },
  160. tableConfig: {
  161. keyField: 'cinemaId',
  162. title: '电影列表',
  163. showAddButton: false,
  164. scrollX: 1800,
  165. fieldMapToTime: [
  166. ['price', ['minPrice', 'maxPrice']],
  167. ['createTime', ['startTime', 'endTime']]
  168. ]
  169. }
  170. });
  171. async function handleSubmitImport(file: File) {
  172. const { error } = await fetchImportGoods({ file });
  173. if (!error) {
  174. importTemplateRef.value?.closeModal();
  175. }
  176. importTemplateRef.value?.setSubLoading(false);
  177. }
  178. function handleModalPrice(row: Api.goods.ShopSku) {
  179. router.push({ path: '/film-manage/setprice', query: { movieId: row.movieId, cinemaId: row.cinemaId } });
  180. }
  181. async function getData() {
  182. const { data, error } = await fetchGetChannelList();
  183. if (!error) {
  184. options.value = data;
  185. }
  186. }
  187. getData();
  188. </script>
  189. <template>
  190. <LayoutTable>
  191. <ZTable :columns="columns" :api="fetchMovieList" @register="registerTable">
  192. <template #op="{ row }">
  193. <NButton size="small" ghost type="primary" @click="handleModalPrice(row)">设置渠道及价格</NButton>
  194. </template>
  195. </ZTable>
  196. <ZImportTemplate
  197. ref="importTemplateRef"
  198. url="/smqjh-pms/api/v1/channelProd/template/download"
  199. template-text="商品渠道及价格导入模版.xlsx"
  200. modal-text="导入商品销售渠道及价格"
  201. @submit="handleSubmitImport"
  202. ></ZImportTemplate>
  203. </LayoutTable>
  204. </template>
  205. <style scoped></style>