content.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <scroll-view scroll-y class="grayBackgroundColor">
  3. <view>
  4. <view
  5. class="whiteBackgroundColor"
  6. style="padding: 15px; margin-bottom: 15px"
  7. v-for="(con, index) in contentList"
  8. :key="index"
  9. >
  10. <view class="siteHeader">
  11. <uni-section :title="con.contentTitle" type="line"></uni-section>
  12. <view style="margin: auto"> </view>
  13. <u-button
  14. v-if="con.remarksBool == false"
  15. type="primary"
  16. icon="list-dot"
  17. style="width: 18px; height: 18px; padding: 0; margin: 0"
  18. shape="circle"
  19. @click="remarksClick(index)"
  20. >
  21. </u-button>
  22. </view>
  23. <view>
  24. <view v-if="con.submissionMethod == 1" style="margin-top: 15px">
  25. <u-checkbox-group
  26. v-model="con.contentOptionListValue1"
  27. @change="
  28. (val) => {
  29. checkboxChange(val, index);
  30. }
  31. "
  32. :disabled="
  33. settingsStore.contentArray.siteList.inspectionStatus == 2
  34. "
  35. >
  36. <u-row style="width: 100%; flex-wrap: wrap">
  37. <u-col
  38. v-for="option in con.contentOptionList"
  39. :key="option"
  40. span="6"
  41. style="margin-bottom: 15px"
  42. >
  43. <u-checkbox
  44. :label="option.optionName"
  45. :name="option.id"
  46. :checked="
  47. con.contentOptionListValue1.length > 0
  48. ? con.contentOptionListValue1.indexOf(option.id) >= 0
  49. : false
  50. "
  51. >
  52. </u-checkbox>
  53. </u-col>
  54. </u-row>
  55. </u-checkbox-group>
  56. <view
  57. v-if="con.remarksBool == true"
  58. style="
  59. display: flex;
  60. height: 32px;
  61. line-height: 32px;
  62. white-space: nowrap;
  63. "
  64. >
  65. <span style="">备注:</span>
  66. <u-input
  67. v-model="con.remarks"
  68. placeholder="请输入备注"
  69. :disabled="
  70. settingsStore.contentArray.siteList.inspectionStatus == 2
  71. "
  72. ></u-input>
  73. </view>
  74. </view>
  75. <view v-if="con.submissionMethod == 2" style="margin-top: 15px">
  76. <u-radio-group placement="row" v-model="con.contentOptionListValue">
  77. <u-row style="width: 100%; flex-wrap: wrap">
  78. <u-col
  79. v-for="option in con.contentOptionList"
  80. :key="option"
  81. :span="6"
  82. style="margin-bottom: 15px"
  83. >
  84. <u-radio
  85. :disabled="
  86. settingsStore.contentArray.siteList.inspectionStatus == 2
  87. "
  88. :label="option.optionName"
  89. :name="option.id"
  90. >
  91. </u-radio>
  92. </u-col>
  93. </u-row>
  94. </u-radio-group>
  95. <view
  96. v-if="con.remarksBool == true"
  97. style="
  98. display: flex;
  99. height: 32px;
  100. line-height: 32px;
  101. white-space: nowrap;
  102. "
  103. >
  104. <span style="">备注:</span>
  105. <u-input
  106. v-model="con.remarks"
  107. placeholder="请输入备注"
  108. :disabled="
  109. settingsStore.contentArray.siteList.inspectionStatus == 2
  110. "
  111. ></u-input>
  112. </view>
  113. </view>
  114. <view v-if="con.submissionMethod == 3" style="margin-top: 15px">
  115. <u-textarea
  116. v-model="con.contentOptionListValue"
  117. placeholder="请输入"
  118. maxlength="30"
  119. :disabled="
  120. settingsStore.contentArray.siteList.inspectionStatus == 2
  121. "
  122. ></u-textarea>
  123. <view
  124. v-if="con.remarksBool == true"
  125. style="
  126. display: flex;
  127. margin-top: 15px;
  128. height: 32px;
  129. line-height: 32px;
  130. white-space: nowrap;
  131. "
  132. >
  133. <span style="">备注:</span>
  134. <u-input
  135. v-model="con.remarks"
  136. placeholder="请输入备注"
  137. :disabled="
  138. settingsStore.contentArray.siteList.inspectionStatus == 2
  139. "
  140. ></u-input>
  141. </view>
  142. </view>
  143. </view>
  144. </view>
  145. <view style="margin-bottom: 125px"></view>
  146. </view>
  147. <view style="position: fixed; left: 0; right: 0; bottom: 0; padding: 15px">
  148. <view>
  149. <u-button
  150. v-if="settingsStore.contentArray.siteList.inspectionStatus == 1"
  151. type="primary"
  152. style="
  153. width: 100%;
  154. height: 40px;
  155. font-size: 14px;
  156. margin-bottom: 15px;
  157. "
  158. shape="circle"
  159. @click="buttonClick(1)"
  160. >
  161. 上一步
  162. </u-button>
  163. </view>
  164. <view>
  165. <u-button
  166. v-if="settingsStore.contentArray.siteList.inspectionStatus == 1"
  167. type="primary"
  168. style="width: 100%; height: 40px; font-size: 14px"
  169. shape="circle"
  170. @click="buttonClick(2)"
  171. >
  172. 提交
  173. </u-button>
  174. </view>
  175. </view>
  176. <u-modal
  177. ref="uModal"
  178. :show="show"
  179. :title="title"
  180. :content="content"
  181. @confirm="confirm"
  182. ></u-modal>
  183. </scroll-view>
  184. </template>
  185. <script setup>
  186. import { onLoad, onShow } from "@dcloudio/uni-app";
  187. import { ref, onMounted, inject, shallowRef } from "vue";
  188. const myRequest = inject("$myRequest");
  189. const BASE_URL = inject("$BASE_URL");
  190. import useXunJianStore from "@/store/modules/xunJian";
  191. const settingsStore = useXunJianStore(); //全局变量值Store
  192. const contentList = ref([]);
  193. function checkboxChange(value, index) {
  194. contentList.value[index].contentOptionListValue1 = value;
  195. }
  196. /**
  197. * @按钮点击事件
  198. * @备注显示事件
  199. */
  200. function remarksClick(index) {
  201. settingsStore.contentArray.contentList[index].remarksBool = true;
  202. }
  203. /**
  204. * @confirm确定回调事件
  205. * @模态框
  206. */
  207. const show = ref(false);
  208. const title = ref("");
  209. const content = ref("");
  210. function confirm() {
  211. show.value = false;
  212. uni.$emit("planSelect"); //执行页面中的自定义方法
  213. uni.navigateBack({
  214. delta: 3, //返回到需要执行方法的页面
  215. });
  216. }
  217. /**
  218. * @按钮点击事件
  219. * @上一步
  220. * @提交
  221. */
  222. async function buttonClick(type) {
  223. if (type == 1) {
  224. //上一步
  225. uni.navigateBack({
  226. delta: 1,
  227. });
  228. } else if (type == 2) {
  229. //提交
  230. const recordOptionList = [];
  231. if (contentList.value.length > 0) {
  232. contentList.value.forEach((e) => {
  233. if (e.contentOptionListValue && e.contentOptionList.length > 0) {
  234. recordOptionList.push({
  235. contentId: e.id,
  236. contentOptionId: e.contentOptionListValue,
  237. remarks: e.remarks,
  238. });
  239. }
  240. if (e.contentOptionListValue && e.contentOptionList.length == 0) {
  241. recordOptionList.push({
  242. contentId: e.id,
  243. content: e.contentOptionListValue,
  244. remarks: e.remarks,
  245. });
  246. }
  247. if (e.contentOptionListValue1.length > 0) {
  248. e.contentOptionListValue1.forEach((l) => {
  249. recordOptionList.push({
  250. contentId: e.id,
  251. contentOptionId: l,
  252. remarks: e.remarks,
  253. });
  254. });
  255. }
  256. });
  257. }
  258. const array = {
  259. siteType: settingsStore.contentArray.siteList.siteType,
  260. siteNubmber: settingsStore.contentArray.siteList.siteNubmber,
  261. siteName: settingsStore.contentArray.siteList.siteName,
  262. siteStatus: 1, //定位 (0:未定位 1:已定位)
  263. longitude: settingsStore.contentArray.siteList.longitude,
  264. latitude: settingsStore.contentArray.siteList.latitude,
  265. planSonId: settingsStore.contentArray.siteList.planSonId,
  266. siteId: settingsStore.contentArray.siteList.id,
  267. recordPictureList: settingsStore.contentArray.siteList.recordPictureList,
  268. recordOptionList: recordOptionList,
  269. };
  270. let res = await myRequest({
  271. url: "/service-fire/appPatrolInspection/updatePlan",
  272. header: {
  273. "Content-Type": "application/json;charset=utf-8",
  274. },
  275. method: "POST",
  276. data: array,
  277. });
  278. if (res.data.status == "SUCCESS") {
  279. title.value = "消息";
  280. content.value = "提交成功,确定后返回!";
  281. show.value = true;
  282. } else {
  283. }
  284. }
  285. }
  286. onLoad((options) => {
  287. contentList.value = settingsStore.contentArray.contentList;
  288. if (settingsStore.contentArray.siteList.inspectionStatus == 2) {
  289. if (contentList.value.length > 0) {
  290. contentList.value.forEach((el) => {
  291. el.contentOptionListValue1 = [];
  292. });
  293. contentList.value.filter((e) => {
  294. if (e.remarks) {
  295. e.remarksBool = true;
  296. } else {
  297. e.remarksBool = false;
  298. }
  299. if (e.contentOptionList) {
  300. e.contentOptionList.forEach((s) => {
  301. if (e.contentOptionValue.indexOf(s.id) >= 0) {
  302. //提交方式:1多选 2单选 3输入框
  303. if (e.submissionMethod == 1) {
  304. e.contentOptionListValue1.push(s.id);
  305. } else if (e.submissionMethod == 2) {
  306. e.contentOptionListValue = s.id;
  307. }
  308. }
  309. });
  310. } else {
  311. e.contentOptionListValue = e.content;
  312. }
  313. });
  314. }
  315. }
  316. });
  317. onMounted(() => {});
  318. </script>
  319. <style scoped>
  320. uni-page-body,
  321. uni-page-refresh,
  322. .grayBackgroundColor {
  323. background: rgb(241, 241, 241);
  324. }
  325. .whiteBackgroundColor {
  326. background-color: #ffffff;
  327. }
  328. </style>
  329. <style lang="scss">
  330. .siteHeader {
  331. display: flex;
  332. height: 18px;
  333. line-height: 18px;
  334. margin-bottom: 10px;
  335. }
  336. </style>