index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <HcCard>
  3. <template #header>
  4. <div class="w-36">
  5. <el-select v-model="searchForm.projectType" block clearable placeholder="项目类型" size="large">
  6. <el-option v-for="item in projectType" :label="item.name" :value="item.key"/>
  7. </el-select>
  8. </div>
  9. <div class="w-40 ml-2">
  10. <el-select v-model="searchForm.projectType" block clearable placeholder="服务类型" size="large">
  11. <el-option v-for="item in projectType" :label="item.name" :value="item.key"/>
  12. </el-select>
  13. </div>
  14. <div class="w-48 ml-2">
  15. <el-input v-model="searchForm.queryValue" clearable placeholder="请输入项目名称进行查询" size="large"/>
  16. </div>
  17. <div class="ml-4">
  18. <el-button type="primary" @click="searchClick" size="large">
  19. <HcIcon name="search-2"/>
  20. <span>搜索</span>
  21. </el-button>
  22. </div>
  23. <div class="ml-2">
  24. <el-button size="large" @click="resetClick">
  25. <HcIcon name="close-circle"/>
  26. <span>重置</span>
  27. </el-button>
  28. </div>
  29. </template>
  30. <template #extra>
  31. <el-button size="large" type="primary" hc-btn @click="updateClick">
  32. <HcIcon name="refresh"/>
  33. <span>合同回款更新</span>
  34. </el-button>
  35. <el-button size="large" type="primary" hc-btn @click="addRowClick">
  36. <HcIcon name="add"/>
  37. <span>新增项目合同信息</span>
  38. </el-button>
  39. </template>
  40. <HcTable :isIndex="false" :column="tableColumn" :datas="tableData" :loading="tableLoading">
  41. <template #name="{row}">
  42. <span class="text-blue" @click="rowNameTap(row)">{{row.name}}</span>
  43. </template>
  44. <template #key4="{row}">
  45. <span class="text-blue text-hover">{{row.startTime+'~'+row.endTime}}</span>
  46. </template>
  47. <template #action="{row,index}">
  48. <el-button plain size="small" type="primary" @click="editRowClick(row)">编辑</el-button>
  49. <el-button plain size="small" type="danger">删除</el-button>
  50. </template>
  51. </HcTable>
  52. <template #action>
  53. <HcPages :pages="searchForm" @change="pageChange"/>
  54. </template>
  55. </HcCard>
  56. </template>
  57. <script setup>
  58. import {ref,onMounted,onActivated} from "vue";
  59. import {useRouter} from 'vue-router'
  60. import contractApi from '~api/project/project-contract.js';
  61. import {getArrValue} from "js-fast-way"
  62. const router = useRouter()
  63. onActivated(()=>{
  64. getTableData()
  65. })
  66. onMounted(()=>{
  67. getTableData()
  68. })
  69. //项目类型
  70. const projectType = ref([
  71. {name: '二级路', key: '二级路'},
  72. {name: '国道', key: '国道'},
  73. {name: '水利水电', key: '水利水电'},
  74. {name: '市政', key: '市政'},
  75. ])
  76. //搜索表单
  77. const searchForm = ref({
  78. projectType: null, user: null, project: null,
  79. current: 1, size: 20, total: 0
  80. })
  81. //搜索
  82. const searchClick = () => {
  83. searchForm.value.current = 1;
  84. getTableData()
  85. }
  86. //重置搜索表单
  87. const resetClick = () => {
  88. searchForm.value = {current: 1, size: 20, total: 0}
  89. }
  90. //分页被点击
  91. const pageChange = ({current, size}) => {
  92. searchForm.value.current = current
  93. searchForm.value.size = size
  94. getTableData()
  95. }
  96. //获取数据
  97. const tableLoading = ref(false)
  98. const tableColumn = [
  99. {key: 'number', name: '合同编号', width: '120', align: 'center'},
  100. {key: 'name', name: '合同名称'},
  101. {key: 'contractTypeValue', name: '合同类型', width: '140', align: 'center'},
  102. {key: 'contractSignTime', name: '签订时间', width: '160', align: 'center'},
  103. {key: 'key4', name: '合同起止日期', width: '220', align: 'center'},
  104. {key: 'returnedMoney', name: '合同已履约回款', width: '140', align: 'center'},
  105. {key: 'unreturnedMoney', name: '合同未履约回款', width: '140', align: 'center'},
  106. {key: 'action', name: '操作', width: '180', align: 'center'},
  107. ]
  108. const tableData = ref([])
  109. const getTableData = async() => {
  110. tableLoading.value = true
  111. const {error, code, data} = await contractApi.getPage(searchForm.value)
  112. tableLoading.value = false
  113. if (!error && code === 200) {
  114. tableData.value = getArrValue(data)
  115. searchForm.value.total = data['total'] || 0
  116. } else {
  117. tableData.value = []
  118. searchForm.value.total = 0
  119. }
  120. }
  121. //预览
  122. const rowNameTap = (row) => {
  123. router.push({
  124. name: 'project-contract-form',
  125. query: {
  126. id: row.id,
  127. type: 'view'
  128. }
  129. })
  130. }
  131. //新增预算
  132. const addRowClick = () => {
  133. router.push({
  134. name: 'project-contract-form',
  135. query: {type: 'add'}
  136. })
  137. }
  138. //编辑预算
  139. const editRowClick = (row) => {
  140. router.push({
  141. name: 'project-contract-form',
  142. query: {
  143. id: row.id,
  144. type: 'edit'
  145. }
  146. })
  147. }
  148. //合同回款更新
  149. const updateClick = () => {
  150. router.push({
  151. name: 'project-contract-update'
  152. })
  153. }
  154. </script>