handling.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. <template>
  2. <view class="container">
  3. <Search ref="searchRef" @reset="reset" @confirm="query"></Search>
  4. <view class="none-data" v-if="dataList.length == 0">
  5. <text>没有 处理中 数据</text>
  6. <image src="/static/image/no-data.png"></image>
  7. </view>
  8. <scroll-view scroll-y="true" @scroll="scroll" :scroll-top="scrollTop" style="height: 540px">
  9. <u-swipe-action>
  10. <view v-if="dataList.length > 0">
  11. <view v-for="(item, index) in dataList" :key="index">
  12. <view class="alarm-box">
  13. <u-swipe-action-item :options="swipeOption" :name="index" @click="viewDetail(item)">
  14. <view class="box-header">
  15. <view class="box-title">{{ item.company_name }}</view>
  16. </view>
  17. </u-swipe-action-item>
  18. <view class="box-body">
  19. <view class="body-item">
  20. <view class="left">公司名称:</view>
  21. <view class="right">{{ item.company_name }}</view>
  22. </view>
  23. <view class="body-item">
  24. <view class="left">区域:</view>
  25. <view class="right">{{ item.org_name }}</view>
  26. </view>
  27. <view class="body-item">
  28. <view class="left">告警类型:</view>
  29. <view class="right">{{ item.warn_type_name }}</view>
  30. </view>
  31. <view class="body-item">
  32. <view class="left">处理状态:</view>
  33. <view class="right">{{ item.work_order_stats_name }}</view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </u-swipe-action>
  40. </scroll-view>
  41. <u-modal v-model="modalDetailInfo" :show="modalDetailShow" :title="modalDetailTitle" :showCancelButton="true" @cancel="modalDetailShow = false" :showConfirmButton="showEditBtn" @confirm="confirmSubmite">
  42. <!-- <view class="slot-content"><rich-text :nodes="content"></rich-text></view> -->
  43. <view class="slot-content" style="width: 100%;">
  44. <scroll-view scroll-y="true" style="height: 200px;">
  45. <view class="modal-item">
  46. <view class="left">公司名称:</view>
  47. <view class="right">{{ modalDetailInfo.warnDetail.company_name }}</view>
  48. </view>
  49. <view class="modal-item">
  50. <view class="left">告警设备:</view>
  51. <view class="right">{{ modalDetailInfo.warnDetail.device_name }}</view>
  52. </view>
  53. <view class="modal-item">
  54. <view class="left">告警类型:</view>
  55. <view class="right">{{ modalDetailInfo.warnDetail.warn_type_name }}</view>
  56. </view>
  57. <view class="modal-item">
  58. <view class="left">告警时间:</view>
  59. <view class="right">{{ modalDetailInfo.warnDetail.warn_start_time }}</view>
  60. </view>
  61. <view v-for="(item2, index2) in modalDetailInfo.processInfoList" :key="index2" style="margin: 10px 0;border-top: 1px solid #333;">
  62. <view class="modal-item">
  63. <view class="left" v-if="item2.work_order_type == 0 || item2.work_order_type == 1">发起人:</view>
  64. <view class="left" v-if="item2.work_order_type == 2">督查审核:</view>
  65. <view class="left" v-if="item2.work_order_type == 3">督查转交:</view>
  66. <view class="left" v-if="item2.work_order_type == 4">现场督查:</view>
  67. <view class="left" v-if="item2.work_order_type == 5">企业上传:</view>
  68. <view class="right" v-if="item2.work_order_type == 0 || item2.work_order_type == 2 || item2.work_order_type == 3 || item2.work_order_type == 4">督查部门</view>
  69. <view class="right" v-if="item2.work_order_type == 1 || item2.work_order_type == 5">企业用户</view>
  70. </view>
  71. <view class="modal-item">
  72. <view class="left">时间:</view>
  73. <view class="right">{{ item2.work_order_process_time }}</view>
  74. </view>
  75. <view class="modal-item">
  76. <view class="left" v-if="item2.work_order_type == 0">催办内容:</view>
  77. <view class="left" v-if="item2.work_order_type == 1">上报备注::</view>
  78. <view class="left" v-if="item2.work_order_type == 2">审核意见:</view>
  79. <view class="left" v-if="item2.work_order_type == 3">备注:</view>
  80. <view class="left" v-if="item2.work_order_type == 4">上报备注:</view>
  81. <view class="left" v-if="item2.work_order_type == 5">上报备注:</view>
  82. <view class="right" v-if="item2.work_order_type == 2">{{ item2.audit_state_name }}</view>
  83. <view class="right" v-if="item2.work_order_type != 2">{{ item2.content }}</view>
  84. </view>
  85. <view class="modal-item" v-if="item2.work_order_type == 2">
  86. <view class="left">备注:</view>
  87. <view class="right">{{ item2.content }}</view>
  88. </view>
  89. <view v-if="item2.picture_url" class="modal-item">
  90. <view class="left" v-if="item2.work_order_type == 1 || item2.work_order_type == 4 || item2.work_order_type == 5">上报文件:</view>
  91. <view class="right"><u--image :showLoading="true" :src="item2.picture_url"></u--image></view>
  92. </view>
  93. </view>
  94. </scroll-view>
  95. <view v-if="showEditBtn">
  96. <u--form>
  97. <u-form-item labelWidth="80px" label="上报图片"><u-upload accept="image" :fileList="fileList" @afterRead="afterRead" @delete="deletePic" name="image" :previewFullImage="true" :maxSize="1024 * 1024 * 2" multiple :maxCount="10"></u-upload></u-form-item>
  98. <u-form-item><u--textarea placeholder="请输入上报备注" v-model="textContent"></u--textarea></u-form-item>
  99. </u--form>
  100. </view>
  101. </view>
  102. </u-modal>
  103. </view>
  104. </template>
  105. <script>
  106. import config from "@/common/config";
  107. import { log } from "@/utils/base.js";
  108. import api from "@/common/api.js";
  109. import Search from "./search.vue";
  110. export default {
  111. name: "handling",
  112. components: {
  113. Search,
  114. },
  115. data() {
  116. return {
  117. needQuery: true,
  118. isQuerying: false,
  119. dataList: [],
  120. fileList: [],
  121. search: {
  122. pageIndex: 1,
  123. pageSize: 10,
  124. params: {
  125. company_name: "",
  126. warn_type: "",
  127. },
  128. },
  129. swipeOption: [
  130. {
  131. text: "上报",
  132. style: {
  133. backgroundColor: "#4cd964",
  134. },
  135. },
  136. ],
  137. scrollTop: 0,
  138. oldScrollTop: 0,
  139. modalDetailShow: false,
  140. modalDetailInfo: {
  141. warnDetail: {},
  142. processInfoList: [],
  143. },
  144. showEditBtn: false,
  145. modalDetailTitle: "上报",
  146. textContent: "",
  147. workOrderId: "",
  148. };
  149. },
  150. mounted() {
  151. this.reset();
  152. },
  153. options: { styleIsolation: "shared" },
  154. methods: {
  155. query(nextPage) {
  156. if (this.needQuery || !nextPage) {
  157. this.search.params.company_name = this.$refs.searchRef.searchInfo.company_name;
  158. this.search.params.warn_type = this.$refs.searchRef.searchInfo.warn_type;
  159. var search = JSON.parse(JSON.stringify(this.search));
  160. if (!search.params.company_name) {
  161. delete search.params.company_name;
  162. }
  163. if (!search.params.warn_type) {
  164. delete search.params.warn_type;
  165. }
  166. if (!nextPage) {
  167. this.dataList = [];
  168. this.needQuery = true;
  169. this.goTop();
  170. }
  171. api.getHandingWorkOrderByOrgLaw(search).then(({ total, rows }) => {
  172. if ((this.search.pageIndex - 1) * this.search.pageSize < total) {
  173. this.dataList.push(...rows);
  174. this.isQuerying = false;
  175. } else {
  176. this.needQuery = false;
  177. }
  178. log("getHandingWorkOrderByOrgLaw", search, rows, this.dataList);
  179. });
  180. }
  181. },
  182. scroll(e) {
  183. this.oldScrollTop = e.detail.scrollTop;
  184. if (e.detail.scrollHeight - e.detail.scrollTop <= 400 && !this.isQuerying) {
  185. //console.log("到达底部");
  186. this.isQuerying = true;
  187. this.search.pageIndex++;
  188. this.query(true);
  189. }
  190. },
  191. goTop() {
  192. this.scrollTop = this.oldScrollTop;
  193. this.$nextTick(() => {
  194. this.scrollTop = 0;
  195. });
  196. },
  197. reset() {
  198. this.search.pageIndex = 1;
  199. this.needQuery = true;
  200. this.isQuerying = false;
  201. this.query();
  202. },
  203. viewDetail(item) {
  204. this.showEditBtn = true;
  205. this.workOrderId = item.work_order_id;
  206. api.getWorkOrderDetailByOrgLaw(item.work_order_id).then(({ data }) => {
  207. log("getWorkOrderDetailByOrgLaw====>", data);
  208. this.modalDetailInfo = data;
  209. this.modalDetailShow = true;
  210. });
  211. },
  212. deletePic(event) {
  213. this.fileList.splice(event.index, 1);
  214. },
  215. async afterRead(event) {
  216. // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
  217. let lists = [].concat(event.file);
  218. let fileListLen = this.fileList.length;
  219. lists.map(item => {
  220. this.fileList.push({
  221. ...item,
  222. status: "uploading",
  223. message: "上传中",
  224. });
  225. });
  226. for (let i = 0; i < lists.length; i++) {
  227. const result = await this.uploadFilePromise(lists[i].url);
  228. let item = this.fileList[fileListLen];
  229. this.fileList.splice(
  230. fileListLen,
  231. 1,
  232. Object.assign(item, {
  233. status: "success",
  234. message: "",
  235. url: result,
  236. })
  237. );
  238. fileListLen++;
  239. }
  240. //console.log("==============", this.fileList);
  241. },
  242. uploadFilePromise(url) {
  243. return new Promise((resolve, reject) => {
  244. let a = uni.uploadFile({
  245. filePath: url,
  246. name: "file",
  247. header: {
  248. Authorization: this.$store.state.token,
  249. cid: "",
  250. },
  251. //#ifdef H5
  252. url: "/api/file/upload/putObject",
  253. //#endif
  254. //#ifndef H5
  255. url: config.baseUrl + "/api/file/upload/putObject",
  256. //#endif
  257. success: ({ data }) => {
  258. data = JSON.parse(data);
  259. resolve(data.data);
  260. //console.log("upload ===>", data);
  261. },
  262. });
  263. });
  264. },
  265. hideDetailModal() {
  266. this.modalDetailShow = false;
  267. },
  268. confirmSubmite() {
  269. if (this.fileList.length <= 0) {
  270. uni.showToast({
  271. type: "error",
  272. position: "top",
  273. title: "上报图片不能空",
  274. });
  275. return;
  276. }
  277. if (!this.textContent) {
  278. uni.showToast({
  279. type: "error",
  280. position: "top",
  281. title: "上报备注不能空",
  282. });
  283. return;
  284. }
  285. const data = {
  286. work_order_id: this.workOrderId,
  287. content: this.textContent,
  288. picture_url: this.buildPicUrl(),
  289. };
  290. //console.log("=========>", data);
  291. api.uploadByOrg(data).then(() => {
  292. uni.showToast({
  293. type: "success",
  294. position: "top",
  295. title: "上报成功",
  296. });
  297. this.modalDetailShow = false;
  298. this.query();
  299. });
  300. },
  301. buildPicUrl(value) {
  302. const result = [];
  303. this.fileList.forEach(v => {
  304. console.log(v);
  305. result.push(v.url.filePath);
  306. });
  307. return result.join(",");
  308. },
  309. },
  310. };
  311. </script>
  312. <style lang="scss">
  313. .container {
  314. padding: 10px 5px;
  315. font-size: 14px;
  316. line-height: 24px;
  317. }
  318. .btn-search-group {
  319. display: flex;
  320. justify-content: space-between;
  321. margin-top: 15px;
  322. }
  323. .none-data {
  324. margin-top: 10%;
  325. display: flex;
  326. flex-direction: column;
  327. justify-content: center;
  328. align-items: center;
  329. font-size: 20px;
  330. color: $uni-color-primary;
  331. }
  332. /deep/ .u-modal {
  333. &__title {
  334. padding-top: 15px;
  335. }
  336. &__content {
  337. padding: 10px;
  338. }
  339. }
  340. .modal-item {
  341. margin: 0;
  342. width: 100%;
  343. display: flex;
  344. flex: 1;
  345. .left {
  346. font-weight: 600;
  347. padding-right: 5px;
  348. white-space: nowrap;
  349. }
  350. }
  351. </style>