plan.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <hc-card id="node-card-plan">
  3. <template #header>
  4. <div class="w-32">
  5. <el-select v-model="searchForm.fileInType" clearable block placeholder="填写类型" @change="getTableData">
  6. <el-option v-for="item in fillType" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  7. </el-select>
  8. </div>
  9. <div class="ml-3 w-64">
  10. <HcDatePicker :dates="betweenTime" clearable @change="betweenTimeUpdate" />
  11. </div>
  12. <div class="ml-3 w-32">
  13. <el-select v-model="searchForm.status" clearable block placeholder="状态 " @change="getTableData">
  14. <el-option v-for="item in tasksStatus" :key="item.dictKey" :label="item.dictValue" :value="item.dictKey" />
  15. </el-select>
  16. </div>
  17. <div class="ml-3 w-32">
  18. <el-select v-model="searchForm.createUser" clearable block placeholder="编写人" @change="getTableData">
  19. <el-option v-for="item in preparedList" :key="item.id" :label="item.name" :value="item.id" />
  20. </el-select>
  21. </div>
  22. <div class="ml-3 w-32">
  23. <el-select v-model="searchForm.sendUser" placeholder="发送人" clearable multiple block @change="getTableData">
  24. <el-option v-for="item in postList" :key="item.batch" :label="item.name" :value="item.id" />
  25. </el-select>
  26. </div>
  27. </template>
  28. <template #extra>
  29. <el-button type="primary" @click="createMonthPlan(1)">
  30. <HcIcon name="add" />
  31. <span>创建月度计划</span>
  32. </el-button>
  33. <el-button type="primary" @click="createMonthPlan(2)">
  34. <HcIcon name="add" />
  35. <span>创建服务计划</span>
  36. </el-button>
  37. </template>
  38. <hc-table :column="tableColumn" :datas="tableData" :loading="tableLoad ">
  39. <template #fileInType="{ row }">
  40. <span>{{ row.fileInType === 1 ? '月度服务计划' : '服务完成确认单' }}</span>
  41. </template>
  42. <template #statusValue="{ row }">
  43. <el-tag
  44. v-if="row?.statusValue"
  45. :type="`${row.statusValue === '已计划' ? 'success' : row.statusValue === '计划中' ? 'info' : 'warning'}`" class="mx-1" effect="dark"
  46. >
  47. {{ row.statusValue }}
  48. </el-tag>
  49. </template>
  50. <template #action="{ row }">
  51. <el-link type="primary" @click="editRow(row)">编辑</el-link>
  52. <el-link type="success">查看</el-link>
  53. <el-link type="warning">删除</el-link>
  54. </template>
  55. </hc-table>
  56. <template #action>
  57. <HcPages :pages="searchForm" @change="pageChange" />
  58. </template>
  59. <fromDrawer v-model="isShowForm" :type="typeVal" :data-id="dataId" />
  60. </hc-card>
  61. </template>
  62. <script setup>
  63. import { nextTick, onMounted, ref } from 'vue'
  64. import fromDrawer from './fromDrawer.vue'
  65. import dataApi from '~api/systemService/service'
  66. import { useAppStore } from '~src/store'
  67. import { arrToId, getArrValue } from 'js-fast-way'
  68. onMounted(()=>{
  69. getTableData()
  70. })
  71. const store = useAppStore()
  72. const projectId = ref(store.getProjectId)
  73. const contractId = ref(store.getContractId)
  74. //搜索表单
  75. const searchForm = ref({
  76. key1: null, ke2: null, key3: null, key4: null, startTimeValue: null, endTimeValue: null,
  77. current: 1, size: 20, total: 0,
  78. })
  79. const fillType = ref([
  80. { dictKey: '1', dictValue: '月度服务计划' },
  81. { dictKey: '2', dictValue: '服务完成确认单' },
  82. ])
  83. const tasksStatus = ref([
  84. { dictKey: '1', dictValue: '计划中' },
  85. { dictKey: '2', dictValue: '协同中-甲方' },
  86. { dictKey: '3', dictValue: '协同中-系统' },
  87. { dictKey: '4', dictValue: '已计划' },
  88. ])
  89. const preparedList = ref([
  90. { id: 1, name: '张三' },
  91. { id: 2, name: '李四' },
  92. ])
  93. const postList = ref([
  94. { id: 1, name: '张三' },
  95. { id: 2, name: '李四' },
  96. ])
  97. //日期时间被选择
  98. const betweenTime = ref(null)
  99. const betweenTimeUpdate = ({ val, arr }) => {
  100. betweenTime.value = arr
  101. searchForm.value.planStartTime = val['start']
  102. searchForm.value.planEndTime = val['end']
  103. getTableData()
  104. }
  105. const searchClick = ()=>{
  106. }
  107. const tableColumn = [
  108. { key: 'fileInType', name: '填写类型' },
  109. { key: 'planTime', name: '计划时间' },
  110. { key: 'statusValue', name: '状态' },
  111. { key: 'createUser', name: '编写人' },
  112. { key: 'createTime', name: '创建时间' },
  113. { key: 'sendUser', name: '发送人员' },
  114. { key: 'action', name: '操作', width:150 },
  115. ]
  116. const tableData = ref([
  117. { name: '名称1', text: '文本1', key3: '已计划' },
  118. { name: '名称2', text: '文本2', key3: '计划中' },
  119. { name: '名称3', text: '文本3', key3: '协同中-甲方' },
  120. ])
  121. //分页被点击
  122. const pageChange = ({ current, size }) => {
  123. searchForm.value.current = current
  124. searchForm.value.size = size
  125. getTableData()
  126. }
  127. const tableLoad = ref(false)
  128. const getTableData = async () => {
  129. tableLoad.value = true
  130. const { error, code, data } = await dataApi.getPage({
  131. projectId: projectId.value,
  132. contractId: contractId.value,
  133. ...searchForm.value,
  134. })
  135. //处理数据
  136. tableLoad.value = false
  137. if (!error && code === 200) {
  138. tableData.value = getArrValue(data['records'])
  139. } else {
  140. tableData.value = []
  141. }
  142. }
  143. const isShowForm = ref(false)
  144. const typeVal = ref('')
  145. const createMonthPlan = (type)=>{
  146. dataId.value = ''
  147. isShowForm.value = true
  148. typeVal.value = type
  149. }
  150. const dataId = ref(null)
  151. const editRow = (row)=>{
  152. isShowForm.value = true
  153. typeVal.value = row.fileInType
  154. dataId.value = row.id
  155. }
  156. </script>