No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

manifestReport.vue 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <script setup>
  2. import { computed, getCurrentInstance, onMounted, ref } from 'vue';
  3. import { useRoute, useRouter } from 'vue-router';
  4. import { showFailToast, showLoadingToast, showSuccessToast } from 'vant';
  5. const base_url = '/sgsafe/TaskManifestReceipt';
  6. const { proxy } = getCurrentInstance();
  7. /* 返回上一级页面 */
  8. const router = useRouter();
  9. const route = useRoute();
  10. const reportingForm = ref({
  11. taskManifestId: '',
  12. completionReporting: '',
  13. completionCount: '1',
  14. completionTime: ''
  15. });
  16. /**
  17. * 获取日期
  18. */
  19. const timeVisible = ref(false);
  20. const timeArr = ref([]);
  21. const formattedTime = computed(() => {
  22. if (timeArr.value.length === 0) {
  23. return '';
  24. }
  25. const date = timeArr.value;
  26. if (!date) return '';
  27. const d = new Date(date);
  28. return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
  29. });
  30. const onConfirmTime = () => {
  31. timeVisible.value = false;
  32. reportingForm.value.completionTime = formattedTime.value;
  33. };
  34. const lowerReportForm = ref({
  35. associateMasterId: ''
  36. })
  37. const dataList = ref([])
  38. const queryLowerReporting = () => {
  39. const url = '/sgsafe/TaskManifestReceipt/queryByManifestId'
  40. const param = {
  41. json: JSON.stringify(lowerReportForm.value)
  42. }
  43. proxy.$axios.post(url, param).then(res => {
  44. if (res.data.code === 0) {
  45. dataList.value = res.data.data;
  46. } else {
  47. showFailToast('查询下级部门汇报失败')
  48. }
  49. })
  50. }
  51. const onSubmit = async (values) => {
  52. const loadingToast = showLoadingToast({
  53. duration: 0,
  54. message: '加载中',
  55. forbidClick: true
  56. });
  57. const url = base_url + '/save';
  58. const params = {
  59. json: JSON.stringify(reportingForm.value)
  60. };
  61. proxy.$axios.post(url, params).then(res => {
  62. if (res.data.code === 0) {
  63. loadingToast.close();
  64. showSuccessToast('保存成功');
  65. router.go(-1)
  66. } else {
  67. loadingToast.close();
  68. showFailToast('操作失败!' + res.data.msg);
  69. }
  70. });
  71. };
  72. const manifest = ref({});
  73. const isQuantified = ref(false);
  74. onMounted(() => {
  75. manifest.value = JSON.parse(route.query.manifest);
  76. console.log('manifest', manifest.value);
  77. if (!manifest.value.id) {
  78. showFailToast('数据错误,请联系管理员');
  79. router.go(-1)
  80. }
  81. lowerReceiptForm.value.associateMasterId = manifest.value.id
  82. reportingForm.value.taskManifestId = manifest.value.id;
  83. isQuantified.value = manifest.value.isQuantified;
  84. queryLowerReporting();
  85. });
  86. </script>
  87. <template>
  88. <div class="page-container">
  89. <van-sticky>
  90. <van-nav-bar title="计划任务汇报">
  91. </van-nav-bar>
  92. </van-sticky>
  93. <div
  94. v-for="(report, index) in dataList"
  95. :key="index"
  96. class="mobile-report-card"
  97. >
  98. <div class="card-header">
  99. <h4>汇报部门: {{ report.reportingDeptName }}</h4>
  100. </div>
  101. <p><strong>汇报内容:</strong> {{ report.completionReporting }}</p>
  102. <p><strong>完成次数:</strong> {{ report.completionCount }}</p>
  103. <p><strong>完成时间:</strong> {{ report.completionTime }}</p>
  104. </div>
  105. <van-form @submit="onSubmit">
  106. <van-field
  107. v-model="reportingForm.completionReporting"
  108. label="汇报内容"
  109. type="textarea"
  110. name="completionReporting"
  111. required
  112. placeholder="请输入汇报内容"
  113. :rules="[{required: true, message: '请输入汇报内容'}]"
  114. />
  115. <van-field
  116. v-if="isQuantified"
  117. v-model="reportingForm.completionCount"
  118. type="number"
  119. label="完成次数"
  120. name="completionCount"
  121. required
  122. :rules="[{required: true, message: '请输入完成次数'},
  123. { pattern: /^[1-9]\d*$/, message: '必须为正整数' }]"
  124. />
  125. <van-field
  126. readonly
  127. v-model="formattedTime"
  128. label="完成时间"
  129. name="formattedTime"
  130. placeholder="请选择完成时间"
  131. required
  132. :rules="[{required: true, message: '请选择完成时间'}]"
  133. @click="timeVisible = true"
  134. />
  135. <div style="margin: 16px;">
  136. <van-button round block type="primary" native-type="submit">提交</van-button>
  137. </div>
  138. </van-form>
  139. <van-popup
  140. :close-on-click-overlay="false"
  141. v-model:show="timeVisible"
  142. position="bottom"
  143. :teleport="false"
  144. >
  145. <van-date-picker
  146. v-model="timeArr"
  147. type="date"
  148. @confirm="onConfirmTime"
  149. @cancel="timeVisible = false"
  150. />
  151. </van-popup>
  152. </div>
  153. </template>
  154. <style scoped>
  155. .page-container {
  156. height: 100vh; /* 关键:外层容器高度设为视口高度 */
  157. display: flex;
  158. flex-direction: column;
  159. }
  160. /* overflow-y: auto; !* 启用垂直滚动 *!*/
  161. .scroll-container {
  162. flex: 1;
  163. overflow: auto;
  164. -webkit-overflow-scrolling: touch; /* iOS 平滑滚动 */
  165. }
  166. /* 可选:隐藏滚动条(视觉优化) */
  167. .scroll-container::-webkit-scrollbar {
  168. display: none;
  169. }
  170. .reports-container {
  171. display: flex;
  172. flex-wrap: wrap;
  173. gap: 16px;
  174. padding: 16px;
  175. }
  176. .report-card .report-header h4 {
  177. margin-top: 0;
  178. font-size: 16px;
  179. color: #333;
  180. }
  181. .report-card p {
  182. margin: 8px 0;
  183. font-size: 14px;
  184. line-height: 1.5;
  185. }
  186. </style>