plan.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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.userId" :label="item.userName" :value="item.userId" />
  20. </el-select>
  21. </div>
  22. <div class="ml-3 w-32">
  23. <el-select v-model="searchForm.sendUser" placeholder="发送人" clearable block @change="getTableData">
  24. <el-option v-for="item in postList" :key="item.userId" :label="item.userName" :value="item.userId" />
  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 v-if="row.status !== 4" type="primary" @click="editRow(row)">编辑</el-link>
  52. <el-link v-if="row.status !== 1 " type="success" @click="viewPlan(row)">查看</el-link>
  53. <el-link v-if="row.status === 1 " v-del-com:[handleDelete]="row" 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" @close="closeDrawer" />
  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. import { toPdfPage } from '~uti/btn-auth'
  69. onMounted(()=>{
  70. getTableData()
  71. getPreparedList()
  72. })
  73. const store = useAppStore()
  74. const projectId = ref(store.getProjectId)
  75. const contractId = ref(store.getContractId)
  76. //搜索表单
  77. const searchForm = ref({
  78. key1: null, ke2: null, key3: null, key4: null, startTimeValue: null, endTimeValue: null,
  79. current: 1, size: 20, total: 0,
  80. })
  81. const fillType = ref([
  82. { dictKey: '1', dictValue: '月度服务计划' },
  83. { dictKey: '2', dictValue: '服务完成确认单' },
  84. ])
  85. const tasksStatus = ref([
  86. { dictKey: '1', dictValue: '计划中' },
  87. { dictKey: '2', dictValue: '确认中-甲方' },
  88. { dictKey: '3', dictValue: '反馈中-系统' },
  89. { dictKey: '4', dictValue: '已计划' },
  90. ])
  91. const preparedList = ref([
  92. ])
  93. const postList = ref([
  94. ])
  95. //日期时间被选择
  96. const betweenTime = ref(null)
  97. const betweenTimeUpdate = ({ val, arr }) => {
  98. betweenTime.value = arr
  99. searchForm.value.planStartTime1 = val['start']
  100. searchForm.value.planEndTime1 = val['end']
  101. getTableData()
  102. }
  103. const tableColumn = [
  104. { key: 'fileInType', name: '填写类型' },
  105. { key: 'planTime', name: '计划时间' },
  106. { key: 'statusValue', name: '状态' },
  107. { key: 'writeUserName', name: '编写人' },
  108. { key: 'createTime', name: '创建时间' },
  109. { key: 'sendUserName', name: '发送人员' },
  110. { key: 'action', name: '操作', width:150 },
  111. ]
  112. const tableData = ref([
  113. ])
  114. //分页被点击
  115. const pageChange = ({ current, size }) => {
  116. searchForm.value.current = current
  117. searchForm.value.size = size
  118. getTableData()
  119. }
  120. const tableLoad = ref(false)
  121. const getTableData = async () => {
  122. tableLoad.value = true
  123. const { error, code, data } = await dataApi.getPage({
  124. projectId: projectId.value,
  125. contractId: contractId.value,
  126. ...searchForm.value,
  127. })
  128. //处理数据
  129. tableLoad.value = false
  130. if (!error && code === 200) {
  131. tableData.value = getArrValue(data['records'])
  132. } else {
  133. tableData.value = []
  134. }
  135. }
  136. //获取发送人
  137. const getPreparedList = async (id) => {
  138. const { error, code, data } = await dataApi.getSendUserAndWriteUser({
  139. projectId: projectId.value,
  140. contractId: contractId.value,
  141. })
  142. //判断状态
  143. if (!error && code === 200) {
  144. preparedList.value = getArrValue(data['writeUser'])
  145. postList.value = getArrValue(data['sendUser'])
  146. } else {
  147. preparedList.value = []
  148. postList.value = []
  149. }
  150. }
  151. const isShowForm = ref(false)
  152. const typeVal = ref('')
  153. const createMonthPlan = (type)=>{
  154. dataId.value = ''
  155. isShowForm.value = true
  156. typeVal.value = type
  157. }
  158. const closeDrawer = ()=>{
  159. isShowForm.value = false
  160. getTableData()
  161. getPreparedList()
  162. }
  163. const dataId = ref(null)
  164. const editRow = (row)=>{
  165. isShowForm.value = true
  166. typeVal.value = row.fileInType
  167. dataId.value = row.id
  168. }
  169. const viewPlan = (row)=>{
  170. const { pdfUrl } = row
  171. if (pdfUrl) {
  172. toPdfPage(pdfUrl)
  173. } else {
  174. window?.$message?.error('暂无预览文件')
  175. }
  176. }
  177. const handleDelete = async ({ item }, resolve) => {
  178. await delData(item.id)
  179. resolve()
  180. }
  181. //删除请求
  182. const delData = async (id) => {
  183. const { error, code, msg, data } = await dataApi.remove({
  184. ids:id,
  185. }, false)
  186. //判断状态
  187. if (!error && code === 200) {
  188. window?.$message?.success(msg)
  189. getTableData()
  190. } else {
  191. window?.$message?.error(msg)
  192. }
  193. }
  194. </script>