index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. <script setup lang="tsx">
  2. import { reactive, ref, unref } from 'vue'
  3. // import { getOrderList, assignSalesman, getOrderDetail } from '@/api/order'
  4. import { getOrderList, getOrderDetail } from '@/api/order'
  5. import { useTable } from '@/hooks/web/useTable'
  6. import { Table, TableColumn } from '@/components/Table'
  7. import { ContentWrap } from '@/components/ContentWrap'
  8. import { FormSchema } from '@/components/Form'
  9. import { Search } from '@/components/Search'
  10. import { Dialog } from '@/components/Dialog'
  11. import { searchTime } from '@/utils/searchTime'
  12. import { searchOrder } from '@/api/order/types'
  13. import { ElTabs, ElTabPane, ElButton, ElDivider, ElDrawer } from 'element-plus'
  14. import Detail from './components/Detail.vue'
  15. import Draft from './components/Draft.vue'
  16. import addItem from './components/addItem.vue'
  17. import { SalespersonButtom } from '@/components/SalespersonList'
  18. const { tableRegister, tableState, tableMethods } = useTable({
  19. fetchDataApi: async () => {
  20. const res = await getOrderList({
  21. ...searchParams.value,
  22. page: unref(currentPage) || 1,
  23. limit: unref(pageSize) || 10,
  24. step: unref(activeName) || 0
  25. })
  26. return {
  27. list: res.data.list || [],
  28. total: res.data.count || 0
  29. }
  30. }
  31. })
  32. const { dataList, loading, total, currentPage, pageSize } = tableState
  33. const { getList } = tableMethods
  34. const dialogVisible = ref(false)
  35. const dialogTitle = ref('')
  36. const showSalesperson = ref(false)
  37. const tableColumns = reactive<TableColumn[]>([
  38. {
  39. field: 'id',
  40. label: 'ID',
  41. align: 'center',
  42. width: 70
  43. },
  44. {
  45. field: 'real_name',
  46. label: '用户',
  47. minWidth: 100,
  48. slots: {
  49. default: (data: any) => {
  50. const row = data.row
  51. return (
  52. <>
  53. <div>昵称: {row.real_name}</div>
  54. <div>UID: {row.uid} </div>
  55. <div>手机号: {row.phone}</div>
  56. </>
  57. )
  58. }
  59. }
  60. },
  61. {
  62. field: 'salesperson',
  63. label: '业务员',
  64. minWidth: 100,
  65. slots: {
  66. default: (data: any) => {
  67. const row = data.row
  68. if(row.salesperson && row.salesperson.id) {
  69. return (
  70. <>
  71. <div> {row.salesperson.name}</div>
  72. </>
  73. )
  74. }else {
  75. return (
  76. <>
  77. </>
  78. )
  79. }
  80. }
  81. }
  82. },
  83. {
  84. field: 'designer',
  85. label: '设计师',
  86. minWidth: 100,
  87. slots: {
  88. default: (data: any) => {
  89. const row = data.row
  90. if(row.designer && row.designer.id) {
  91. return (
  92. <>
  93. <div> {row.designer.name}</div>
  94. </>
  95. )
  96. }else {
  97. return (
  98. <>
  99. </>
  100. )
  101. }
  102. }
  103. }
  104. },
  105. {
  106. field: 'worker',
  107. label: '安装工',
  108. minWidth: 100,
  109. slots: {
  110. default: (data: any) => {
  111. const row = data.row
  112. if(row.worker && row.worker.id) {
  113. return (
  114. <>
  115. <div> {row.worker.name}</div>
  116. </>
  117. )
  118. }else {
  119. return (
  120. <>
  121. </>
  122. )
  123. }
  124. }
  125. }
  126. },
  127. {
  128. field: 'address',
  129. label: '地址',
  130. minWidth: 100
  131. },
  132. {
  133. field: 'price',
  134. label: '金额',
  135. minWidth: 100
  136. },
  137. {
  138. field: 'area',
  139. label: '预估面积',
  140. minWidth: 100
  141. },
  142. {
  143. field: 'add_time',
  144. label: '时间',
  145. minWidth: 160
  146. },
  147. {
  148. field: 'mark',
  149. label: '备注',
  150. minWidth: 140
  151. },
  152. {
  153. field: 'action',
  154. label: '操作',
  155. width: 200,
  156. headerAlign: 'center',
  157. align: 'center',
  158. slots: {
  159. default: (data: any) => {
  160. const row = data.row;
  161. return (
  162. <>
  163. <ElButton type="primary" link size="small" onClick={() => action('edit', row)}>详情</ElButton>
  164. <ElDivider direction="vertical" />
  165. <ElButton type="primary" link size="small">详情</ElButton>
  166. </>
  167. )
  168. }
  169. }
  170. }
  171. ])
  172. const searchSchema = reactive<FormSchema[]>([
  173. {
  174. field: 'uid',
  175. label: 'UID',
  176. component: 'Input',
  177. componentProps: {
  178. type: 'number',
  179. placeholder: '请输入用户UID'
  180. }
  181. },
  182. {
  183. field: 'real_name',
  184. label: '用户昵称',
  185. component: 'Input',
  186. componentProps: {
  187. placeholder: '请输入用户昵称'
  188. }
  189. },
  190. {
  191. field: 'salesperson_id',
  192. label: '业务员',
  193. component: 'Input',
  194. componentProps: {
  195. type: 'number',
  196. placeholder: '请选择业务员'
  197. }
  198. },
  199. {
  200. field: 'order_id',
  201. label: '订单号',
  202. component: 'Input',
  203. componentProps: {
  204. placeholder: '请输入订单号'
  205. }
  206. },
  207. searchTime
  208. ])
  209. const searchParams = ref<searchOrder>({
  210. uid: '',
  211. real_name: '',
  212. time: '',
  213. store_id: '',
  214. salesperson_id: '',
  215. step: '',
  216. order_id: ''
  217. })
  218. const setSearchParams = (data: any) => {
  219. searchParams.value = data
  220. const search = searchParams.value
  221. if (data.time) {
  222. search.time = data.time.join('-')
  223. } else {
  224. search.time = ''
  225. }
  226. getList()
  227. }
  228. const activeName = ref(0)
  229. const tabsConfig = reactive([
  230. {
  231. title: '待付款',
  232. total: 0,
  233. step: 0
  234. },
  235. {
  236. title: '设计师订单',
  237. total: 0,
  238. step: 1
  239. },
  240. {
  241. title: '商品订单',
  242. total: 0,
  243. step: 2
  244. },
  245. {
  246. title: '安装订单',
  247. total: 0,
  248. step: 3
  249. },
  250. {
  251. title: '待评价',
  252. total: 0,
  253. step: 4
  254. },
  255. {
  256. title: '已完成',
  257. total: 0,
  258. step: 5
  259. }
  260. ])
  261. const activeNames = ref(0)
  262. const currentRow = ref()
  263. const tabsConfigs = reactive([
  264. {
  265. title: '基本信息',
  266. total: 0,
  267. step: 0
  268. },
  269. {
  270. title: '设计稿',
  271. total: 0,
  272. step:1
  273. },
  274. {
  275. title: '增项',
  276. total: 0,
  277. step:2
  278. },
  279. ])
  280. const getLists = (e)=> {
  281. console.log(e)
  282. }
  283. const checkedSalesperson = (e) => {
  284. console.log(e)
  285. currentRow.value.salesperson_id = e.id;
  286. currentRow.value.salesperson = e
  287. }
  288. const action = async (type: string, row?: any) => {
  289. // actionType.value = type
  290. // if (type == 'add') {
  291. // dialogTitle.value = t('exampleDemo.add')
  292. // currentRow.value = undefined
  293. // }
  294. // console.log(currentRow, 'currentRow')
  295. // }
  296. const res = await getOrderDetail(row.id)
  297. if (type == 'edit') {
  298. dialogTitle.value = '详情'
  299. currentRow.value = res.data
  300. console.log(row,'row');
  301. dialogVisible.value = true
  302. }
  303. }
  304. // const goAssignSalesman = async (id:number, data: any) => {
  305. // await assignSalesman(id,data)
  306. // }
  307. </script>
  308. <template>
  309. <ContentWrap>
  310. <ElTabs v-model="activeName" @tab-click="getList">
  311. <ElTabPane
  312. v-for="(item, index) in tabsConfig"
  313. :key="index"
  314. :label="`${item.title}${item.total > 0 ? `(${item.total})` : ''}`"
  315. :name="index"
  316. />
  317. </ElTabs>
  318. <div class="max-w-1000px">
  319. <Search isCol :schema="searchSchema" @reset="setSearchParams" @search="setSearchParams" />
  320. </div>
  321. <div class="mb-10px"> </div>
  322. <Table
  323. v-model:current-page="currentPage"
  324. v-model:page-size="pageSize"
  325. :columns="tableColumns"
  326. default-expand-all
  327. node-key="id"
  328. stripe
  329. :data="dataList"
  330. :loading="loading"
  331. @register="tableRegister"
  332. :pagination="{
  333. total
  334. }"
  335. />
  336. </ContentWrap>
  337. <ElDrawer
  338. v-model="dialogVisible"
  339. :title="dialogTitle"
  340. direction="rtl"
  341. size="50%"
  342. >
  343. <ElTabs v-model="activeNames" >
  344. <ElTabPane
  345. v-for="(item, index) in tabsConfigs"
  346. :key="index"
  347. :label="`${item.title}${item.total > 0 ? `(${item.total})` : ''}`"
  348. :name="index"
  349. />
  350. </ElTabs>
  351. <Detail v-if="activeNames === 0" :current-row="currentRow" @checkedSalesperson="checkedSalesperson"/>
  352. <Draft v-if="activeNames === 1" :current-row="currentRow" />
  353. <addItem v-if="activeNames === 2" :current-row="currentRow" />
  354. </ElDrawer>
  355. </template>