CustomReport.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template>
  2. <div v-for="(item, index) in prop.form.customPushConfigList">
  3. <div v-if="item.isDeleted != 1" class="reportCard">
  4. <a v-if="!disableType.contentDisable">
  5. <el-icon
  6. class="cardIcon"
  7. color="rgb(216,216,216)"
  8. v-if="prop.form.customPushConfigList.filter((custom) => custom.isDeleted === 0).length > 1"
  9. @click="deleteReportCard(index)"
  10. >
  11. <CircleCloseFilled />
  12. </el-icon>
  13. </a>
  14. <el-form-item label="统计区间:" required>
  15. <el-form-item
  16. :prop="`customPushConfigList[` + index + `].customStartTime`"
  17. :rules="[{ required: true, message: '请选择推统计区间', trigger: 'change' }]"
  18. >
  19. <el-col :span="22">
  20. <el-date-picker
  21. v-model="item.daterange"
  22. style="width: 327.5px"
  23. type="daterange"
  24. range-separator="至"
  25. start-placeholder="开始日期"
  26. end-placeholder="结束日期"
  27. size="default"
  28. value-format="YYYY-MM-DD"
  29. :disabled="disableType.contentDisable"
  30. />
  31. </el-col>
  32. </el-form-item>
  33. </el-form-item>
  34. <el-form-item label="推送时间:" required>
  35. <el-form-item
  36. :prop="`customPushConfigList[` + index + `].pushDay`"
  37. :rules="{ required: true, message: '请选择推送日期', trigger: 'change' }"
  38. >
  39. <el-col :span="22">
  40. <el-date-picker
  41. v-model="item.pushDay"
  42. type="date"
  43. placeholder="选择日期"
  44. :disabled-date="disabledDate"
  45. size="default"
  46. style="width: 146.5px; height: 32px"
  47. value-format="YYYY-MM-DD"
  48. :disabled="disableType.contentDisable"
  49. />
  50. </el-col>
  51. </el-form-item>
  52. <el-col class="text-center" :span="2" style="padding-bottom: 10px">
  53. <span class="text-gray-500">—</span>
  54. </el-col>
  55. <el-form-item
  56. :prop="`customPushConfigList[` + index + `].pushTime`"
  57. :rules="{ required: true, message: '请选择推送时间', trigger: 'change' }"
  58. >
  59. <el-col :span="22">
  60. <el-time-picker
  61. v-model="item.pushTime"
  62. placeholder="选择时间"
  63. value-format="HH:mm:ss"
  64. style="width: 146.5px; height: 32px"
  65. :disabled="disableType.contentDisable"
  66. />
  67. </el-col>
  68. </el-form-item>
  69. </el-form-item>
  70. <el-form-item
  71. label="推送对象:"
  72. required
  73. :prop="`customPushConfigList[` + index + `].recipientType`"
  74. :rules="{ required: true, message: '请选择推送对象', trigger: 'change' }"
  75. >
  76. <el-radio-group v-model="item.recipientType" :disabled="disableType.contentDisable">
  77. <el-radio value="1">全员</el-radio>
  78. <el-radio value="2">分组</el-radio>
  79. <el-radio value="3">自定义</el-radio>
  80. </el-radio-group>
  81. </el-form-item>
  82. <el-form-item
  83. v-if="item.recipientType === '2'"
  84. label="选择分组:"
  85. required
  86. style="margin-top: 10px"
  87. :prop="`customPushConfigList[` + index + `].userGroupList`"
  88. :rules="{ required: true, message: '请选择分组', trigger: 'change' }"
  89. >
  90. <el-col :span="10">
  91. <el-select
  92. v-model="item.userGroupList"
  93. multiple
  94. placeholder="请选择分组"
  95. style="width: 326px; padding-bottom: 0px"
  96. :disabled="disableType.contentDisable"
  97. >
  98. <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
  99. </el-select>
  100. </el-col>
  101. </el-form-item>
  102. <!-- :rules="{validator: validateCustom, trigger: 'change' }" -->
  103. <!-- :rules="{validator: (rule, value, cb) => validateCustom(rule, value, cb, index), trigger: 'change' }" -->
  104. <!-- :rules="{ required: true, message: '请选择推送人员', trigger: 'change' }" -->
  105. <el-form-item
  106. v-if="item.recipientType === '3'"
  107. label="选择人员:"
  108. required
  109. placeholder="请选择人员"
  110. style="width: 526px; margin-top: 10px"
  111. :prop="`customPushConfigList[` + index + `].customUserList`"
  112. :rules="{ required: true, message: '请选择推送人员', trigger: 'blur' }"
  113. >
  114. <el-col :span="18">
  115. <CustomPersonSelection
  116. style="padding-bottom: 0"
  117. :form="form"
  118. :disableType="disableType"
  119. :index="index"
  120. :statisticType="5"
  121. :ruleFormRef="ruleFormRef"
  122. />
  123. </el-col>
  124. </el-form-item>
  125. </div>
  126. </div>
  127. <el-button type="primary" :icon="Plus" @click="addCustom" class="addButton" :disabled="disableType.contentDisable"
  128. >新建自定义</el-button
  129. >
  130. </template>
  131. <script lang="ts" setup>
  132. import { ref, reactive, onMounted } from 'vue';
  133. import { computeCustom, createCustomReport } from './class.ts';
  134. import { CircleCloseFilled } from '@element-plus/icons-vue';
  135. import { searchGroup } from '@/api/message/report-message';
  136. import CustomPersonSelection from './components/CustomPersonSelection.vue';
  137. import { Plus } from '@element-plus/icons-vue';
  138. const prop = defineProps(['form', 'disableType', 'ruleFormRef']);
  139. const emit = defineEmits(['customPropsChange']);
  140. if (prop.form.customPushConfigList.length === 0) {
  141. prop.form.customPushConfigList = reactive<computeCustom[]>([]);
  142. const defaultReport = createCustomReport();
  143. prop.form.customPushConfigList.push(defaultReport);
  144. }
  145. const options = ref();
  146. const addCustom = () => {
  147. prop.form.customPushConfigList.push(createCustomReport());
  148. };
  149. const deleteReportCard = (index) => {
  150. prop.form.customPushConfigList[index].isDeleted = 1;
  151. // prop.form.customPushConfigList.splice(index, 1);
  152. };
  153. const disabledDate = (time: Date) => {
  154. return time.getTime() < Date.now() - 8.64e7; //如果没有后面的-8.64e7就是不可以选择今天的
  155. };
  156. onMounted(() => {
  157. searchGroup()
  158. .then((res) => {
  159. options.value = res.groupVOList;
  160. })
  161. .catch((e) => {
  162. console.log(e);
  163. });
  164. });
  165. </script>
  166. <style scoped>
  167. .reportCard {
  168. margin-left: 87px;
  169. margin-bottom: 16px;
  170. padding: 12px 0px 0px 12px;
  171. background-color: #fafafa;
  172. width: 530px;
  173. position: relative;
  174. }
  175. .addButton {
  176. margin-top: 16px;
  177. margin-bottom: 32px;
  178. margin-left: 87px;
  179. width: 124px;
  180. height: 32px;
  181. background: #ffffff;
  182. border-radius: 4px;
  183. border: 1px dashed #1790ff;
  184. color: #1890ff;
  185. }
  186. .cardIcon {
  187. position: absolute;
  188. right: 0px;
  189. top: 0px;
  190. width: 14px;
  191. height: 14px;
  192. }
  193. .el-form-item--default {
  194. /* margin-bottom: 8px; */
  195. margin-bottom: 0px;
  196. padding-bottom: 10px;
  197. }
  198. .reportCard > .el-form-item:last-child {
  199. /* background:#ff0000; */
  200. padding-bottom: 16px;
  201. }
  202. ::v-deep .el-select__selection {
  203. min-height: 25px;
  204. }
  205. </style>