index.vue 8.0 KB

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