content.vue 9.3 KB

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