content.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <scroll-view class="scroll-height" :scroll-y="true" :data-theme="'theme-' + proxy.$settingStore.themeColor.name">
  3. <view class="xunjian-plan-content">
  4. <view class="bg-white padding-15 margin-b-15" v-for="(con, index) in contentList" :key="index">
  5. <view class="flex margin-bottom-10">
  6. <uni-section :title="con.contentTitle" type="line"></uni-section>
  7. <view style="margin: auto"> </view>
  8. <u-button v-if="con.remarksBool == false" type="primary" icon="list-dot" style="width: 18px; height: 18px; padding: 0; margin: 0" shape="circle" @click="remarksClick(index)"> </u-button>
  9. </view>
  10. <view>
  11. <view class="margin-t-15" v-if="con.submissionMethod == 1">
  12. <u-checkbox-group
  13. v-model="con.contentOptionListValue1"
  14. @change="
  15. (val) => {
  16. checkboxChange(val, index);
  17. }
  18. "
  19. :disabled="xunJianStore.contentArray.siteList.inspectionStatus == 2"
  20. :activeColor="proxy.$settingStore.themeColor.color"
  21. >
  22. <u-row style="width: 100%; flex-wrap: wrap">
  23. <u-col class="margin-b-15" v-for="option in con.contentOptionList" :key="option" :span="6">
  24. <u-checkbox :label="option.optionName" :name="option.id" :checked="con.contentOptionListValue1.length > 0 ? con.contentOptionListValue1.indexOf(option.id) >= 0 : false">
  25. </u-checkbox>
  26. </u-col>
  27. </u-row>
  28. </u-checkbox-group>
  29. <view v-if="con.remarksBool == true" style="display: flex; height: 32px; line-height: 32px; white-space: nowrap">
  30. <span>备注:</span>
  31. <u-input v-model="con.remarks" placeholder="请输入备注" :disabled="xunJianStore.contentArray.siteList.inspectionStatus == 2"></u-input>
  32. </view>
  33. </view>
  34. <view class="margin-t-15" v-if="con.submissionMethod == 2">
  35. <u-radio-group placement="row" v-model="con.contentOptionListValue" :activeColor="proxy.$settingStore.themeColor.color">
  36. <u-row style="width: 100%; flex-wrap: wrap">
  37. <u-col class="margin-b-15" v-for="option in con.contentOptionList" :key="option" :span="6">
  38. <u-radio :disabled="xunJianStore.contentArray.siteList.inspectionStatus == 2" :label="option.optionName" :name="option.id"> </u-radio>
  39. </u-col>
  40. </u-row>
  41. </u-radio-group>
  42. <view v-if="con.remarksBool == true" style="display: flex; height: 32px; line-height: 32px; white-space: nowrap">
  43. <span>备注:</span>
  44. <u-input v-model="con.remarks" placeholder="请输入备注" :disabled="xunJianStore.contentArray.siteList.inspectionStatus == 2"></u-input>
  45. </view>
  46. </view>
  47. <view class="margin-t-15" v-if="con.submissionMethod == 3">
  48. <u-textarea
  49. class="margin-b-15"
  50. v-model="con.contentOptionListValue"
  51. placeholder="请输入"
  52. maxlength="30"
  53. :disabled="xunJianStore.contentArray.siteList.inspectionStatus == 2"
  54. ></u-textarea>
  55. <view v-if="con.remarksBool == true" style="display: flex; height: 32px; line-height: 32px; white-space: nowrap">
  56. <span>备注:</span>
  57. <u-input v-model="con.remarks" placeholder="请输入备注" :disabled="xunJianStore.contentArray.siteList.inspectionStatus == 2"></u-input>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. <view class="app-button-fixed">
  64. <u-button class="app-buttom" v-if="xunJianStore.contentArray.siteList.inspectionStatus == 1" type="primary" shape="circle" @click="buttonClick(1)"> 上一步 </u-button>
  65. <u-button class="app-buttom" v-if="xunJianStore.contentArray.siteList.inspectionStatus == 1" type="primary" shape="circle" @click="buttonClick(2)"> 提交 </u-button>
  66. </view>
  67. <u-modal ref="uModal" :show="show" :title="title" :content="content" @confirm="confirm"></u-modal>
  68. </scroll-view>
  69. </template>
  70. <script setup>
  71. import { onLoad, onShow } from "@dcloudio/uni-app";
  72. import { ref, onMounted, reactive, computed, getCurrentInstance, toRefs, inject, shallowRef } from "vue";
  73. import { publicStores, xunJianStores } from "@/store/modules/index";
  74. import { updatePlan } from "@/api/business/mhxf/xunJian/plan.js";
  75. const BASE_URL = inject("$BASE_URL");
  76. const xunJianStore = xunJianStores(); //全局变量值Store
  77. const { proxy } = getCurrentInstance();
  78. const contentList = ref([]);
  79. function checkboxChange(value, index) {
  80. contentList.value[index].contentOptionListValue1 = value;
  81. }
  82. /**
  83. * @按钮点击事件
  84. * @备注显示事件
  85. */
  86. function remarksClick(index) {
  87. xunJianStore.contentArray.contentList[index].remarksBool = true;
  88. }
  89. /**
  90. * @confirm确定回调事件
  91. * @模态框
  92. */
  93. const show = ref(false);
  94. const title = ref("");
  95. const content = ref("");
  96. function confirm() {
  97. show.value = false;
  98. uni.$emit("planSelect"); //执行页面中的自定义方法
  99. uni.navigateBack({
  100. delta: 3, //返回到需要执行方法的页面
  101. });
  102. }
  103. /**
  104. * @按钮点击事件
  105. * @上一步
  106. * @提交
  107. */
  108. async function buttonClick(type) {
  109. if (type == 1) {
  110. //上一步
  111. uni.navigateBack({
  112. delta: 1,
  113. });
  114. } else if (type == 2) {
  115. //提交
  116. const recordOptionList = [];
  117. if (contentList.value.length > 0) {
  118. contentList.value.forEach((e) => {
  119. if (e.contentOptionListValue && e.contentOptionList.length > 0) {
  120. recordOptionList.push({
  121. contentId: e.id,
  122. contentOptionId: e.contentOptionListValue,
  123. remarks: e.remarks,
  124. });
  125. }
  126. if (e.contentOptionListValue && e.contentOptionList.length == 0) {
  127. recordOptionList.push({
  128. contentId: e.id,
  129. content: e.contentOptionListValue,
  130. remarks: e.remarks,
  131. });
  132. }
  133. if (e.contentOptionListValue1.length > 0) {
  134. e.contentOptionListValue1.forEach((l) => {
  135. recordOptionList.push({
  136. contentId: e.id,
  137. contentOptionId: l,
  138. remarks: e.remarks,
  139. });
  140. });
  141. }
  142. });
  143. }
  144. const array = {
  145. siteType: xunJianStore.contentArray.siteList.siteType,
  146. siteNubmber: xunJianStore.contentArray.siteList.siteNubmber,
  147. siteName: xunJianStore.contentArray.siteList.siteName,
  148. siteStatus: 1, //定位 (0:未定位 1:已定位)
  149. longitude: xunJianStore.contentArray.siteList.longitude,
  150. latitude: xunJianStore.contentArray.siteList.latitude,
  151. planSonId: xunJianStore.contentArray.siteList.planSonId,
  152. siteId: xunJianStore.contentArray.siteList.id,
  153. recordPictureList: xunJianStore.contentArray.siteList.recordPictureList,
  154. recordOptionList: recordOptionList,
  155. };
  156. updatePlan(array).then((res) => {
  157. if (res.status == "SUCCESS") {
  158. title.value = "消息";
  159. content.value = "提交成功,确定后返回!";
  160. show.value = true;
  161. } else {
  162. }
  163. });
  164. }
  165. }
  166. onLoad((options) => {
  167. contentList.value = xunJianStore.contentArray.contentList;
  168. if (xunJianStore.contentArray.siteList.inspectionStatus == 2) {
  169. if (contentList.value.length > 0) {
  170. contentList.value.forEach((el) => {
  171. el.contentOptionListValue1 = [];
  172. });
  173. contentList.value.filter((e) => {
  174. if (e.remarks) {
  175. e.remarksBool = true;
  176. } else {
  177. e.remarksBool = false;
  178. }
  179. if (e.contentOptionList) {
  180. e.contentOptionList.forEach((s) => {
  181. if (e.contentOptionValue.indexOf(s.id) >= 0) {
  182. //提交方式:1多选 2单选 3输入框
  183. if (e.submissionMethod == 1) {
  184. e.contentOptionListValue1.push(s.id);
  185. } else if (e.submissionMethod == 2) {
  186. e.contentOptionListValue = s.id;
  187. }
  188. }
  189. });
  190. } else {
  191. e.contentOptionListValue = e.content;
  192. }
  193. });
  194. }
  195. }
  196. });
  197. onShow(() => {
  198. //调用系统主题颜色
  199. proxy.$settingStore.systemThemeColor([1]);
  200. });
  201. onMounted(() => {});
  202. </script>
  203. <style lang="scss">
  204. .xunjian-plan-content {
  205. //#ifdef H5
  206. padding-bottom: 125px;
  207. //#endif
  208. //#ifdef APP-PLUS
  209. padding-bottom: 130px;
  210. //#endif
  211. }
  212. </style>