enterpriseVisitorItem.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <view class="enterpriseSituateItem">
  3. <view class="d-flex px-4">
  4. <view class="w-100 font-md text-dark font-weight">对接方式</view>
  5. </view>
  6. <view class="px-4">
  7. <u--form labelPosition="left" :model="model" ref="situateForm" labelWidth="100">
  8. <u-form-item label="" prop="dealResult">
  9. <u-radio-group v-model="model.staffTotal" placement="row" @change="groupChange">
  10. <u-radio :label="item.name" :name="item.value" class="mx-1" v-for="(item,index) in list"
  11. :key="index"></u-radio>
  12. </u-radio-group>
  13. </u-form-item>
  14. <u-form-item :label="list[model.staffTotal?model.staffTotal-1:0]['name']+'记录时间:'" prop="endDate"
  15. @click="endDateTap">
  16. <u--input v-model="model.endDate" readonly :border="onlyFlag ? 'none' : 'surround'"
  17. :placeholder="!onlyFlag ? '请选择近期与企业沟通时间' : ''">
  18. </u--input>
  19. </u-form-item>
  20. </u--form>
  21. <!-- 年月控件 -->
  22. <!-- <u-datetime-picker :show="showDatetime" mode="date" @confirm="calendarConfirm" @close="showDatetime=false"
  23. @cancel="showDatetime=false" :minDate="1704038400000" confirmDisabledText="请选择截止日期" closeOnClickOverlay>
  24. </u-datetime-picker> -->
  25. </view>
  26. <u-calendar :minDate="minDate" :maxDate="maxDate" :show="showDatetime" @close="showDatetime=false"
  27. @confirm="calendarConfirm"></u-calendar>
  28. </view>
  29. </template>
  30. <script>
  31. import {formatDate} from "@/common/util2.js"
  32. export default {
  33. props: {
  34. model: {
  35. type: Object,
  36. default: () => {}
  37. },
  38. readOnlyFlag: {
  39. type: Boolean,
  40. default: false
  41. }
  42. },
  43. data() {
  44. return {
  45. showDatetime: false,
  46. monthType: '',
  47. list: [{
  48. name: "上门沟通",
  49. value: '1'
  50. },
  51. {
  52. name: "电话联系",
  53. value: '2'
  54. },
  55. {
  56. name: "平台沟通",
  57. value: '3'
  58. },
  59. ]
  60. }
  61. },
  62. computed: {
  63. onlyFlag() {
  64. return this.readOnlyFlag
  65. },
  66. minDate() {
  67. const now = new Date();
  68. console.log(now.getFullYear())
  69. const previousMonth = this.getPreviousMonth(now.getFullYear(), now.getMonth() + 1, now.getDate());
  70. return previousMonth
  71. },
  72. maxDate() {
  73. const now = new Date();
  74. const nextMonth = this.getNextMonth(now.getFullYear(), now.getMonth() + 1, now.getDate());
  75. return nextMonth
  76. }
  77. },
  78. methods: {
  79. getPreviousMonth(year, month, day) {
  80. if (month === 1) {
  81. // 如果是1月,则前一个月是上一年的12月
  82. return year - 1 + '-12-' + day;
  83. } else {
  84. // 对于其他月份,直接减1即可
  85. return year + '-' + (month - 1) + '-' + day;
  86. }
  87. },
  88. getNextMonth(year, month, day) {
  89. if (month === 12) {
  90. // 如果是12月,则下一个月是下年的1月
  91. return year + 1 + '-01-' + day;
  92. } else {
  93. // 对于其他月份,直接加1即可
  94. return year + '-' + (month + 1) + '-' + day;
  95. }
  96. },
  97. // 持续到哪个月-->点击
  98. endDateTap(e) {
  99. if (this.readOnlyFlag) return
  100. this.showDatetime = true;
  101. this.hideKeyboard()
  102. },
  103. // 持续到哪个月-->日期选择确认
  104. calendarConfirm(e) {
  105. this.showDatetime = false
  106. this.model.endDate = e[0]
  107. },
  108. // 隐藏键盘
  109. hideKeyboard() {
  110. uni.hideKeyboard()
  111. },
  112. groupChange(ele) {
  113. this.model.staffTotal = ele
  114. },
  115. },
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .enterpriseSituateItem {
  120. .commomWidth {
  121. width: 400rpx;
  122. .month {
  123. width: 150rpx;
  124. }
  125. .monthDesc {
  126. width: 230rpx;
  127. }
  128. }
  129. }
  130. </style>