index.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <u-navbar :titleStyle="{ color: '#fff' }" :autoBack="true" title="异常上报" :placeholder="true" :safeAreaInsetTop="true" :bgColor="proxy.$settingStore.themeColor.color">
  3. <template #left>
  4. <view class="u-navbar__content__left__item">
  5. <u-icon name="arrow-left" size="20" color="#fff"></u-icon>
  6. </view>
  7. </template>
  8. </u-navbar>
  9. <oa-scroll
  10. customClass="error-container scroll-height"
  11. :customStyle="{ height: `calc(100vh - (44px + ${proxy.$settingStore.StatusBarHeight} + ${proxy.$settingStore.tabBarHeight}))` }"
  12. :refresherLoad="false"
  13. :refresherEnabled="false"
  14. :refresherEnabledTitle="false"
  15. :refresherDefaultStyle="'none'"
  16. :refresherThreshold="44"
  17. :refresherBackground="'#f5f6f7'"
  18. :data-theme="'theme-' + proxy.$settingStore.themeColor.name"
  19. >
  20. <template #default>
  21. <u--form ref="uForm" :model="form" :rules="rules" labelWidth="90">
  22. <view style="padding: 10px 10px 20px 20px; background: #ffffff">
  23. <u-form-item label="姓名" prop="nickName" required :borderBottom="true">
  24. <u-input v-model="form.nickName" placeholder="姓名(必填)" border="none" maxlength="50" disabledColor="transparent" disabled />
  25. </u-form-item>
  26. <u-form-item label="事件名称" prop="eventName" required :borderBottom="true">
  27. <u-input v-model="form.eventName" placeholder="事件名称(必填)" border="none" maxlength="50" />
  28. </u-form-item>
  29. <u-form-item label="事件分类" prop="eventCategory" required :borderBottom="true" @click="handleAction('事件分类')">
  30. <u-input v-model="form.eventCategoryName" placeholder="事件分类(必选)" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
  31. </u-form-item>
  32. <u-form-item label="事件类型" prop="eventType" required :borderBottom="true" @click="handleAction('事件类型')">
  33. <u-input v-model="form.eventTypeName" placeholder="事件类型(必选)" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
  34. </u-form-item>
  35. <u-form-item label="事件等级" prop="eventLevel" required :borderBottom="true" @click="handleAction('事件等级')">
  36. <u-input v-model="form.eventLevelName" placeholder="事件类型(必选)" suffixIcon="arrow-right" suffixIconStyle="color: #909399" border="none" disabledColor="transparent" disabled />
  37. </u-form-item>
  38. <u-form-item label="现场图片" prop="pictureUrl" :borderBottom="true">
  39. <oa-upload :uploadCount="5" :uploadList="form.imageList" :uploadListSrc="'url'" @uploadSuccessChange="uploadSuccessChange" @uploadDeleteChange="uploadDeleteChange"></oa-upload>
  40. </u-form-item>
  41. <u-form-item label="备注" prop="remark" :borderBottom="true">
  42. <u--textarea v-model="form.remark" placeholder="备注信息,最多可输入50个字" :count="true" border="none" maxlength="50"></u--textarea>
  43. </u-form-item>
  44. </view>
  45. </u--form>
  46. <view class="app-button">
  47. <view class="app-button-padding"></view>
  48. <view class="app-button-fixed">
  49. <u-button class="app-buttom" type="primary" @click="handleSubmit()" shape="circle"> 上报异常 </u-button>
  50. </view>
  51. </view>
  52. <u-picker
  53. :show="actionShow"
  54. :columns="actionsList"
  55. :title="'请选择' + actionTitle"
  56. keyName="label"
  57. visibleItemCount="6"
  58. :defaultIndex="[actionDefaultIndex]"
  59. :closeOnClickOverlay="true"
  60. @close="actionShow = false"
  61. @cancel="actionShow = false"
  62. @confirm="selectAction"
  63. ></u-picker>
  64. </template>
  65. </oa-scroll>
  66. </template>
  67. <script setup>
  68. /*----------------------------------依赖引入-----------------------------------*/
  69. import { onLoad, onShow, onHide, onLaunch, onReady } from "@dcloudio/uni-app";
  70. import { ref, onMounted, inject, shallowRef, reactive, toRefs, getCurrentInstance, computed } from "vue";
  71. /*----------------------------------接口引入-----------------------------------*/
  72. import { errorApi } from "@/api/business/zhaf/xunJian/index.js";
  73. /*----------------------------------组件引入-----------------------------------*/
  74. /*----------------------------------store引入-----------------------------------*/
  75. import { useStores, commonStores } from "@/store/modules/index";
  76. /*----------------------------------公共方法引入-----------------------------------*/
  77. /*----------------------------------公共变量-----------------------------------*/
  78. const { proxy } = getCurrentInstance();
  79. const useStore = useStores();
  80. const commonStore = commonStores();
  81. const { patrol_event_classify, patrol_event_grade, patrol_event_type } = proxy.useDict("patrol_event_classify", "patrol_event_grade", "patrol_event_type");
  82. /*----------------------------------变量声明-----------------------------------*/
  83. const state = reactive({
  84. form: {
  85. nickName: computed(() => {
  86. return useStore.nickName;
  87. }),
  88. eventCategory: "", //事件分类
  89. eventCategoryName: "", //事件分类名称
  90. eventType: "", //事件类型
  91. eventTypeName: "", //事件类型名称
  92. eventLevel: "", //事件等级
  93. eventLevelName: "", //事件等级名称
  94. remark: "", //备注
  95. deviceId: computed(() => {
  96. return proxy.$settingStore.deviceList.deviceId;
  97. }), //设备Id
  98. planId: undefined, //计划Id
  99. imageList: [],
  100. },
  101. rules: {
  102. nickName: [{ required: true, message: "请输入姓名", trigger: ["blur", "change"] }],
  103. eventCategory: [{ required: true, message: "请选择事件分类", trigger: ["blur", "change"] }],
  104. eventType: [{ required: true, message: "请选择事件类型", trigger: ["blur", "change"] }],
  105. eventLevel: [{ required: true, message: "请选择事件等级", trigger: ["blur", "change"] }],
  106. },
  107. actionIndex: 0,
  108. actionTitle: "",
  109. actionShow: false,
  110. actionDefaultIndex: 0,
  111. actionsList: [[]],
  112. });
  113. const { form, rules, actionTitle, actionIndex, actionsList, actionShow, actionDefaultIndex } = toRefs(state);
  114. /**
  115. * @按钮点击事件
  116. */
  117. function handleSubmit(value) {
  118. if (!proxy.$common.isNetwork()) {
  119. return false;
  120. }
  121. proxy.$refs["uForm"]
  122. .validate()
  123. .then((res) => {
  124. var param = {
  125. eventName: state.form.eventName, //事件名称
  126. eventType: state.form.eventType, //事件类型
  127. eventLevel: state.form.eventLevel, //事件等级
  128. eventCategory: state.form.eventCategory, //事件分类
  129. deviceId: state.form.deviceId, //设备Id
  130. planId: state.form.planId, //计划Id
  131. eventImage: JSON.stringify(state.form.imageList),
  132. remark: state.form.remark,
  133. };
  134. errorApi()
  135. .Insert(param)
  136. .then(() => {
  137. proxy.$modal.msg("提交成功");
  138. proxy.$tab.navigateBack(1);
  139. })
  140. .catch((err) => {
  141. proxy.$modal.msg(err);
  142. });
  143. })
  144. .catch((errors) => {
  145. proxy.$modal.msg("校验失败");
  146. });
  147. }
  148. /**
  149. * @action弹出框点击事件
  150. */
  151. function handleAction(value, index, ind) {
  152. if (value == "事件分类") {
  153. state.actionTitle = "事件分类";
  154. state.actionIndex = index;
  155. state.actionsList[0] = patrol_event_classify.value;
  156. state.actionDefaultIndex = 0;
  157. }
  158. if (value == "事件类型") {
  159. state.actionTitle = "事件类型";
  160. state.actionIndex = index;
  161. state.actionsList[0] = patrol_event_type.value;
  162. state.actionDefaultIndex = 0;
  163. }
  164. if (value == "事件等级") {
  165. state.actionTitle = "事件等级";
  166. state.actionIndex = index;
  167. state.actionsList[0] = patrol_event_grade.value;
  168. state.actionDefaultIndex = 0;
  169. }
  170. state.actionShow = true;
  171. }
  172. /**
  173. * @action弹出框选择事件
  174. */
  175. function selectAction(e) {
  176. if (state.actionTitle == "事件分类") {
  177. state.form.eventCategory = e.value[0].value;
  178. state.form.eventCategoryName = e.value[0].label;
  179. }
  180. if (state.actionTitle == "事件类型") {
  181. state.form.eventType = e.value[0].value;
  182. state.form.eventTypeName = e.value[0].label;
  183. }
  184. if (state.actionTitle == "事件等级") {
  185. state.form.eventLevel = e.value[0].value;
  186. state.form.eventLevelName = e.value[0].label;
  187. }
  188. state.actionShow = false;
  189. }
  190. /**
  191. * @图片上传成功回调
  192. */
  193. function uploadSuccessChange(e) {
  194. state.form.imageList.push({
  195. name: e.name,
  196. url: e.url,
  197. });
  198. }
  199. /**
  200. * @图片删除回调
  201. */
  202. function uploadDeleteChange(e) {
  203. state.form.imageList = e;
  204. }
  205. onLoad((options) => {});
  206. onShow(() => {
  207. //调用系统主题颜色
  208. proxy.$settingStore.systemThemeColor([1]);
  209. });
  210. </script>
  211. <style lang="scss">
  212. .error-container {
  213. :deep(.u-picker__view__column__item) {
  214. font-size: 13px;
  215. }
  216. }
  217. </style>