index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="h-full flex">
  3. <div class="p-5 w-80 pr-0">
  4. <div class="bg-white w-full h-full shadow-md rounded-md flex flex-col">
  5. <div class="flex-1 p-3 overflow-y-auto">
  6. <!-- 筛选条件 -->
  7. <el-form :model="filterForm" label-width="70px" style="max-width: 600px">
  8. <template v-for="(item, index) in filterItems">
  9. <el-form-item :label="item.label" v-if="item.type != 'date'">
  10. <el-input v-if="item.type === 'input'" v-model="filterForm[item.key as keyof FilterForm]" clearable
  11. placeholder="请输入"></el-input>
  12. <el-select v-else v-model="filterForm[item.key as keyof FilterForm]" placeholder="请选择" clearable>
  13. <el-option v-for="option in item.options" :key="option.id" :label="option.name" :value="option.id" />
  14. </el-select>
  15. </el-form-item>
  16. <template v-if="item.type == 'date'">
  17. <el-form-item :label="item.label">
  18. <el-date-picker v-model="filterForm.startTime" type="date" placeholder="请选择" :clearable="false"
  19. format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
  20. </el-form-item>
  21. <el-form-item label="">
  22. <el-date-picker v-model="filterForm.endTime" type="date" placeholder="请选择" :clearable="false"
  23. format="YYYY-MM-DD" value-format="YYYY-MM-DD" />
  24. </el-form-item>
  25. </template>
  26. </template>
  27. </el-form>
  28. </div>
  29. <div class="w-full flex p-3 shadow-[0_-3px_5px_0px_rgba(0,0,0,0.2)]">
  30. <El-button class="w-full" @click="resetFilterForm()">重置</El-Button>
  31. <El-button type="primary" class="w-full" @click="getTableList()">搜索</El-Button>
  32. </div>
  33. </div>
  34. </div>
  35. <div class="flex-1 p-5 overflow-auto">
  36. <div class="bg-white w-full h-full p-3 shadow-md rounded-md flex flex-col">
  37. <div class="flex justify-end pb-3">
  38. <!-- 操作按钮 -->
  39. <el-button v-for="(button, index) in actionButtons" :key="index" type="primary">{{ button.text }}</el-button>
  40. </div>
  41. <div class="flex-1 w-full overflow-hidden">
  42. <!-- 表格 -->
  43. <el-table ref="otherTableRef" :data="formTable" border v-loading="allLoading.formTableLading"
  44. style="width: 100%;height: 100%;">
  45. <el-table-column v-for="(column, index) in tableColumns" :key="index" :prop="column.prop"
  46. :label="column.label" :width="column.width">
  47. <template #default="scope">
  48. <template v-if="column.event === 'toDetali'">
  49. <el-button link type="primary" size="large" @click="toDetali(scope.row)">{{ scope.row[column.prop]
  50. }}</el-button>
  51. </template>
  52. </template>
  53. </el-table-column>
  54. <el-table-column :label="'操作'" :width="'200px'" fixed="right">
  55. <template #default="scope">
  56. <el-button link type="primary" size="large">编辑</el-button>
  57. <el-button link type="primary" size="large">新建任务</el-button>
  58. <el-button link type="danger" size="large">删除</el-button>
  59. </template>
  60. </el-table-column>
  61. </el-table>
  62. </div>
  63. <div class="flex justify-end pt-3">
  64. <!-- 分页 -->
  65. <el-pagination layout="total, prev, pager, next, sizes" :total="formTablePaging.total"
  66. :hide-on-single-page="true" />
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </template>
  72. <script lang="ts" setup>
  73. import { ref, reactive, onMounted, inject } from "vue";
  74. import { getAllListByCode, getFromValue, resetFromValue, getFirstDayOfMonth, getLastDayOfMonth, formatDate } from '@/utils/tools'
  75. import { post, get } from "@/utils/request";
  76. import { actionButtons, tableColumns, GETSYSFILED, GETPERSONNEL, GETGENERATEFOEM, MOD, GETTABLELIST, GETALLPRODUCT } from "./api";
  77. import { useRouter, useRoute } from "vue-router";
  78. import { URL_FETALL } from "../customer/api";
  79. const router = useRouter()
  80. const filterForm = reactive<FilterForm>({ // 筛选条件 Value
  81. contactPerson: "",
  82. customerId: "",
  83. phoneNumber: '',
  84. responsibleId: '',
  85. createId: '',
  86. email: '',
  87. startTime: getFirstDayOfMonth(new Date()),
  88. endTime: formatDate(new Date())
  89. });
  90. const selectData = reactive({ // 下拉数据
  91. Personnel: [] as personnelInterface[],
  92. Customer: [] as any[], // 客户名称
  93. OrderType: [] as any[], // 订单类型
  94. RemittanceStatus: [{ id: 0, name: '已回款' }, { id: 1, name: '未回款' }, { id: 2, name: '已完全回款' }] as any[], // 回款状态
  95. AllProduct: [] as any[] // 所有产品
  96. })
  97. const filterItems = ref<FilterItem[]>([]) // 渲染筛选条件
  98. const formTablePaging = reactive({ // 分页条件
  99. currentPage: 1,
  100. pageSize: 10,
  101. total: 0,
  102. })
  103. const generateFormData = ref([]) // 自定义表单数据
  104. const formTable = ref([]) // 表格数据
  105. const allLoading = reactive({ // 按钮加载 Loading
  106. formTableLading: false,
  107. })
  108. const allVisible = reactive({
  109. })
  110. function toDetali(row: any) {
  111. router.push({
  112. path: `${MOD}/detail`,
  113. query: { id: row.id }
  114. })
  115. }
  116. function getTableList() {
  117. const formValue = getFromValue(filterForm)
  118. const formPaging = { pageIndex: formTablePaging.currentPage, pageSize: formTablePaging.pageSize }
  119. allLoading.formTableLading = true
  120. post(GETTABLELIST, { ...formValue, ...formPaging }).then(res => {
  121. const { total, record } = res.data
  122. formTable.value = record
  123. formTablePaging.total = total
  124. }).finally(() => {
  125. allLoading.formTableLading = false
  126. })
  127. }
  128. function resetFilterForm() {
  129. let newFilterForm = resetFromValue(filterForm, { startTime: getFirstDayOfMonth(new Date()), endTime: formatDate(new Date()) })
  130. Object.assign(filterForm, newFilterForm)
  131. getTableList()
  132. }
  133. function getAllProduct() {
  134. get(GETALLPRODUCT, { pageIndex: -1, pageSize: -1 }).then((res) => {
  135. const { record } = res.data
  136. selectData.AllProduct = record
  137. })
  138. }
  139. async function getSystemField() {
  140. const systemField = getAllListByCode(['订单类型'])
  141. for (let i in systemField) {
  142. const { data } = await get(`${GETSYSFILED}?code=${systemField[i]}`)
  143. for (let key of Object.keys(selectData)) {
  144. if (systemField[i] == key) {
  145. Object.assign(selectData, { [key]: data })
  146. }
  147. }
  148. }
  149. const { data: personnelData } = await post(GETPERSONNEL, {})
  150. selectData.Personnel = personnelData.map((item: any) => {
  151. const { id, name, phone, jobNumber } = item
  152. return { id, name, phone, jobNumber }
  153. })
  154. const { data: customerData } = await post(URL_FETALL, {})
  155. selectData.Customer = (customerData || []).map((item: any) => {
  156. const { id, customName } = item
  157. return { id, name: customName }
  158. })
  159. // const res = await get(GETGENERATEFOEM)
  160. // generateFormData.value = JSON.parse(res.data[0].config)
  161. setFilterItems()
  162. }
  163. function setFilterItems() {
  164. filterItems.value = [
  165. { label: '订单编号', key: 'orderCode', type: 'input' },
  166. { label: '订单名称', key: 'orderName', type: 'input' },
  167. { label: '客户名称', key: 'customId', type: 'select', options: selectData.Customer },
  168. { label: '商机名称', key: 'businessOpportunityId', type: 'input' },
  169. { label: '订单类型', key: 'ordertype', type: 'select', options: selectData.OrderType },
  170. { label: '回款状态', key: 'receivedStatus', type: 'select', options: selectData.RemittanceStatus },
  171. { label: '负责人', key: 'inchargerId', type: 'select', options: selectData.Personnel },
  172. { label: '下单时间', key: '', type: 'date' },
  173. ]
  174. }
  175. onMounted(() => {
  176. getSystemField()
  177. getAllProduct()
  178. getTableList()
  179. })
  180. </script>
  181. <style lang="scss" scoped></style>