external.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. <!-- @format -->
  2. <template>
  3. <view class="container">
  4. <view v-show="isOptional" style="margin-top: 20rpx">
  5. <view style="color: #3c9cff" class="informationTitle"
  6. >免备案或者没有匹配到检定单位的器具,可自主选择检定机构,或直接去省外溯源</view
  7. >
  8. <view class="chooseType">
  9. <u-form
  10. :model="optional"
  11. ref="optionRef"
  12. labelWidth="140"
  13. labelPosition="top"
  14. >
  15. <u-form-item label="器具数量:" labelPosition="left">
  16. <view
  17. style="
  18. display: flex;
  19. justify-content: space-between;
  20. align-items: center;
  21. "
  22. >
  23. <span
  24. style="margin-left: -115rpx; font-size: 30rpx; color: #fa3534"
  25. >
  26. {{ optional.count }}
  27. </span>
  28. <view style="width: 150rpx">
  29. <u-button
  30. @click="handleDetails(optional)"
  31. size="mini"
  32. type="primary"
  33. >查看器具</u-button
  34. >
  35. </view>
  36. </view>
  37. </u-form-item>
  38. <u-form-item label="选择方式:" :required="true" prop="type">
  39. <u-radio-group v-model="optional.type">
  40. <u-radio label="提交到检定机构" name="0"></u-radio>
  41. <view style="margin-left: 40rpx">
  42. <u-radio label="去省外溯源" name="1"></u-radio>
  43. </view>
  44. </u-radio-group>
  45. </u-form-item>
  46. <u-form-item
  47. v-if="optional.type == '0'"
  48. label="检定机构:"
  49. :required="true"
  50. prop="organizationId"
  51. >
  52. <zxz-uni-data-select
  53. dataKey="name"
  54. dataValue="id"
  55. @inputChange="hadnleSearch"
  56. :filterable="true"
  57. v-model="optional.organizationId"
  58. placeholder="请输入单位名称自动查找"
  59. :localdata="localdata"
  60. emptyTips="没有查找到单位"
  61. ></zxz-uni-data-select>
  62. </u-form-item>
  63. </u-form>
  64. </view>
  65. </view>
  66. <view v-show="isInadmissible" style="margin-top: 20rpx">
  67. <view style="color: #3c9cff" class="informationTitle"
  68. >上次检定结果为不予受理的器具,可自主选择检定机构。</view
  69. >
  70. <view class="chooseType">
  71. <u-form
  72. :model="Inadmissible"
  73. ref="inadFormRef"
  74. labelWidth="140"
  75. labelPosition="top"
  76. >
  77. <u-form-item label="器具数量:" labelPosition="left">
  78. <view
  79. style="
  80. display: flex;
  81. justify-content: space-between;
  82. align-items: center;
  83. "
  84. >
  85. <span
  86. style="margin-left: -115rpx; font-size: 30rpx; color: #fa3534"
  87. >
  88. {{ Inadmissible.count }}
  89. </span>
  90. <view style="width: 150rpx">
  91. <u-button
  92. @click="handleDetails(Inadmissible)"
  93. size="mini"
  94. type="primary"
  95. >查看器具</u-button
  96. >
  97. </view>
  98. </view>
  99. </u-form-item>
  100. <u-form-item
  101. label="检定机构:"
  102. :required="true"
  103. prop="organizationId"
  104. >
  105. <zxz-uni-data-select
  106. dataKey="name"
  107. dataValue="id"
  108. @inputChange="hadnleSearch"
  109. :filterable="true"
  110. v-model="Inadmissible.organizationId"
  111. placeholder="请输入单位名称自动查找"
  112. :localdata="localdata"
  113. emptyTips="没有查找到单位"
  114. ></zxz-uni-data-select>
  115. </u-form-item>
  116. </u-form>
  117. </view>
  118. </view>
  119. <view v-if="autoAllocation.length" style="margin-top: 20rpx">
  120. <view style="color: #3c9cff" class="informationTitle"
  121. >系统自动分配的检定机构</view
  122. >
  123. <view
  124. v-for="item of autoAllocation"
  125. :key="item.measuringId"
  126. class="inforItems"
  127. >
  128. <view class="content">
  129. <view class="title">器具数量:</view>
  130. <view class="message" style="width: 533rpx">
  131. <view
  132. style="
  133. display: flex;
  134. justify-content: space-between;
  135. align-items: center;
  136. flex: 1;
  137. "
  138. >
  139. <span style="font-size: 30rpx; color: #fa3534">{{
  140. item.count
  141. }}</span>
  142. <view style="width: 150rpx">
  143. <u-button
  144. @click="handleDetails(item)"
  145. size="mini"
  146. type="primary"
  147. >查看器具</u-button
  148. >
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. <view class="content">
  154. <view class="title">检定机构:</view>
  155. <view class="message">{{ item.organizationName }}</view>
  156. </view>
  157. </view>
  158. </view>
  159. <view style="height: 100rpx"></view>
  160. <view class="btn">
  161. <view style="width: 90%; margin: 0 auto">
  162. <u-button @click="onSubmit" :disabled="isLoading" type="primary"
  163. >提交</u-button
  164. >
  165. </view>
  166. </view>
  167. </view>
  168. </template>
  169. <script>
  170. import {
  171. assignOrganization,
  172. listMechanismLikeName,
  173. startSubmitCheckOrder,
  174. } from "@/api/verification";
  175. import { getInfo } from "@/api/login.js";
  176. export default {
  177. data() {
  178. return {
  179. isLoading: false,
  180. autoAllocation: [],
  181. optional: {
  182. organizationId: null,
  183. type: "0",
  184. },
  185. isOptional: true,
  186. isInadmissible: true,
  187. method: "",
  188. Inadmissible: {
  189. organizationId: null,
  190. },
  191. ids: [],
  192. localdata: [],
  193. userMobile: "",
  194. optionRules: {
  195. type: [
  196. {
  197. required: true,
  198. message: "选择方式不能为空",
  199. trigger: "blur",
  200. },
  201. ],
  202. organizationId: [
  203. {
  204. required: true,
  205. message: "检定机构不能为空",
  206. trigger: "blur",
  207. },
  208. ],
  209. },
  210. inadFormRules: {
  211. organizationId: [
  212. {
  213. required: true,
  214. message: "检定机构不能为空",
  215. trigger: "blur",
  216. },
  217. ],
  218. },
  219. };
  220. },
  221. methods: {
  222. //查看详情
  223. handleDetails(item) {
  224. uni.navigateTo({
  225. url: "/pages/verification/utensils?ids=" + item.instrumentIds.join(","),
  226. success: (res) => {},
  227. fail: () => {},
  228. complete: () => {},
  229. });
  230. },
  231. async onSubmit() {
  232. if (this.isOptional) {
  233. await this.$refs.optionRef.validate();
  234. }
  235. if (this.isInadmissible) {
  236. await this.$refs.inadFormRef.validate();
  237. }
  238. uni.showLoading({
  239. title: "提交中...",
  240. });
  241. this.isLoading = true;
  242. try {
  243. let res = await startSubmitCheckOrder({
  244. assignResult: [
  245. ...this.autoAllocation,
  246. this.optional,
  247. this.Inadmissible,
  248. ].filter(Boolean),
  249. instrIds: this.ids,
  250. checkMethod: this.checkMethod,
  251. userMobile: this.userMobile,
  252. });
  253. uni.showToast({
  254. title: "提交成功",
  255. duration: 2000,
  256. });
  257. setTimeout(() => {
  258. let dataPramr = res.data.checkOrder;
  259. uni.reLaunch({
  260. url:
  261. "/pages/verification/institution?id=" +
  262. dataPramr.id +
  263. "&danwei=" +
  264. dataPramr.instrumentSummary +
  265. "&applypeople=" +
  266. dataPramr.startUserName +
  267. "&userMobile=" +
  268. dataPramr.startUserMobile +
  269. "&createTime=" +
  270. dataPramr.createTime +
  271. "&checkMethod=" +
  272. dataPramr.checkMethod,
  273. success: (res) => {},
  274. fail: () => {},
  275. complete: () => {},
  276. });
  277. });
  278. this.isLoading = false;
  279. } finally {
  280. this.isLoading = false;
  281. }
  282. },
  283. async hadnleSearch(row) {
  284. let { data } = await listMechanismLikeName({
  285. mechanismName: row,
  286. });
  287. this.localdata = data;
  288. },
  289. },
  290. onReady() {
  291. //如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则。
  292. this.$refs.optionRef.setRules(this.optionRules);
  293. this.$refs.inadFormRef.setRules(this.inadFormRules);
  294. },
  295. async onLoad(options) {
  296. this.checkMethod = options.type;
  297. this.ids = options.ids.split(",");
  298. uni.showLoading({
  299. title: "加载中...",
  300. });
  301. try {
  302. let { data } = await assignOrganization(this.ids);
  303. this.autoAllocation = data.filter((element) => element.chooseType == 0);
  304. this.optional = data.filter((element) => element.chooseType == 2)[0];
  305. this.Inadmissible = data.filter((element) => element.chooseType == 1)[0];
  306. this.isOptional = data.filter(
  307. (element) => element.chooseType == 2
  308. ).length;
  309. this.isInadmissible = data.filter(
  310. (elementItem) => elementItem.chooseType == 1
  311. ).length;
  312. this.optional.type = "0";
  313. } finally {
  314. setTimeout(() => {
  315. uni.hideLoading();
  316. }, 2000);
  317. }
  318. getInfo().then((res) => {
  319. this.userMobile = res.data.mechanism.userMobile;
  320. });
  321. },
  322. };
  323. </script>
  324. <style lang="scss" scoped>
  325. .btn {
  326. background: #fff;
  327. width: 100%;
  328. position: fixed;
  329. bottom: 0;
  330. left: 0;
  331. padding: 20rpx;
  332. }
  333. .chooseType {
  334. background: #fff;
  335. border-radius: 8px;
  336. margin: 20rpx 0 0;
  337. padding: 20rpx;
  338. }
  339. .content {
  340. border-bottom: 1px solid rgb(242, 242, 242);
  341. padding: 24rpx 0;
  342. display: flex;
  343. // justify-content: space-between;
  344. }
  345. .content:last-child {
  346. border-bottom: none;
  347. }
  348. .title {
  349. font-size: 26rpx;
  350. color: black;
  351. letter-spacing: 3rpx;
  352. }
  353. .message {
  354. font-size: 26rpx;
  355. color: rgb(146, 146, 146);
  356. }
  357. .inforItems {
  358. background: #fff;
  359. border-radius: 8px;
  360. margin: 20rpx 0;
  361. padding: 20rpx;
  362. }
  363. .container {
  364. height: 100vh;
  365. background: rgb(243, 244, 249);
  366. width: 95%;
  367. margin: 20rpx auto;
  368. }
  369. .informationTitle {
  370. margin-bottom: 10rpx;
  371. font-size: 30;
  372. }
  373. </style>