billDetail.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436
  1. <template>
  2. <div class="full-container-p24">
  3. <div class="df mb10 aic">
  4. <h5 class="mr20">请选择单据:</h5>
  5. <el-checkbox
  6. v-model="isCheckAll"
  7. @change="checkAll"
  8. :indeterminate="isIndeterminate"
  9. size="large"
  10. style="margin-right: 20px"
  11. >全选</el-checkbox
  12. >
  13. </div>
  14. <div v-show="fileList?.length" class="df aic fww">
  15. <div
  16. style="
  17. width: 100px;
  18. text-align: center;
  19. margin-right: 20px;
  20. margin-bottom: 20px;
  21. "
  22. v-for="item in fileList"
  23. :key="item.id"
  24. >
  25. <el-image
  26. style="height: 100px; width: 100px"
  27. fit="contain"
  28. :src="item.viewUrl"
  29. :preview-src-list="previewList"
  30. ></el-image>
  31. <div style="width: 100px; text-align: center; font-size: 12px">
  32. {{ item.createTime }}
  33. </div>
  34. <div class="tac">
  35. <el-checkbox
  36. @change="checkItem"
  37. v-model="item.checked"
  38. size="large"
  39. ></el-checkbox>
  40. </div>
  41. </div>
  42. </div>
  43. <div
  44. v-show="!fileList?.length"
  45. style="text-align: center; font-size: 24px; color: #ccc"
  46. >
  47. 暂无单据图片
  48. </div>
  49. <div v-if="recordIds.length" class="mb20">
  50. <h5 class="mb10">请选择单据类型:</h5>
  51. <div class="df aic distribute-group mb20">
  52. <el-button
  53. class="mr20"
  54. :type="distributeType == 1 ? 'primary' : ''"
  55. @click="distributeType = 1"
  56. size="small"
  57. >运单</el-button
  58. >
  59. <el-button
  60. class="mr20"
  61. :type="distributeType == 2 ? 'primary' : ''"
  62. @click="distributeType = 2"
  63. size="small"
  64. >磅单</el-button
  65. >
  66. <el-button
  67. class="mr20"
  68. :type="distributeType == 4 ? 'primary' : ''"
  69. @click="distributeType = 4"
  70. size="small"
  71. >汽运装货单</el-button
  72. >
  73. <el-button @click="fail" size="small" type="danger">不通过</el-button>
  74. </div>
  75. <div v-if="distributeType != -1" class="mb20">
  76. <h5 class="mb10">请选择卸货港:</h5>
  77. <div class="df aic distribute-group">
  78. <el-button
  79. v-for="(item, index) in discPorts"
  80. class="mr20"
  81. :type="distributePortId == item.portId ? 'primary' : ''"
  82. @click="distributePortId = item.portId"
  83. size="small"
  84. >{{ item.portName }}</el-button
  85. >
  86. </div>
  87. </div>
  88. <div v-show="distributeType == 2">
  89. <el-form inline :model="distributePoundForm">
  90. <el-form-item label="卸货时间">
  91. <el-date-picker
  92. class="info-line-text"
  93. v-model="distributePoundForm.dischargeTime"
  94. type="datetime"
  95. format="YYYY/MM/DD HH:mm:ss"
  96. value-format="YYYY/MM/DD HH:mm:ss"
  97. placeholder="卸货时间"
  98. ></el-date-picker>
  99. </el-form-item>
  100. <el-form-item label="卸货吨位">
  101. <el-input
  102. class="info-line-text"
  103. v-model="distributePoundForm.dischargeTons"
  104. placeholder="卸货吨位"
  105. ></el-input>
  106. </el-form-item>
  107. <el-form-item label="卸货件数">
  108. <el-input
  109. class="info-line-text"
  110. v-model="distributePoundForm.dischargePieces"
  111. placeholder="卸货件数"
  112. ></el-input>
  113. </el-form-item>
  114. </el-form>
  115. </div>
  116. <div v-show="distributeType == 4">
  117. <div class="tar">
  118. <el-button @click="ocr" :loading="ocrLoading" type="primary">{{
  119. ocrLoading ? "正在识别" : "开始识别"
  120. }}</el-button>
  121. </div>
  122. <el-table :data="ocrTruckRecordTableData" stripe max-height="500">
  123. <el-table-column label="港口名称" min-width="200" align="center">
  124. <template v-slot="scope">
  125. <el-input size="small" v-model="scope.row.portName"></el-input>
  126. </template>
  127. </el-table-column>
  128. <!-- <el-table-column label="称重时间" min-width="200" align="center">
  129. <template v-slot="scope">
  130. <el-date-picker
  131. size="small"
  132. class="info-line-text"
  133. v-model="scope.row.weighTime"
  134. type="datetime"
  135. format="YYYY/MM/DD HH:mm:ss"
  136. value-format="YYYY/MM/DD HH:mm:ss"
  137. placeholder="称重时间"
  138. ></el-date-picker>
  139. </template>
  140. </el-table-column> -->
  141. <el-table-column label="称重时间" min-width="120" align="center">
  142. <template v-slot="scope">
  143. <el-input
  144. :input-style="
  145. scope.row.weighTime ? {} : { border: '1px solid red' }
  146. "
  147. size="small"
  148. v-model="scope.row.weighTime"
  149. ></el-input>
  150. </template>
  151. </el-table-column>
  152. <el-table-column label="车号" min-width="120" align="center">
  153. <template v-slot="scope">
  154. <el-input
  155. :input-style="
  156. scope.row.carNum?.length == 7
  157. ? {}
  158. : { border: '1px solid red' }
  159. "
  160. size="small"
  161. v-model="scope.row.carNum"
  162. ></el-input>
  163. </template>
  164. </el-table-column>
  165. <el-table-column label="货物名称" min-width="120" align="center">
  166. <template v-slot="scope">
  167. <el-input size="small" v-model="scope.row.cargoName"></el-input>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="发货单位" min-width="200" align="center">
  171. <template v-slot="scope">
  172. <el-input
  173. size="small"
  174. v-model="scope.row.shippingUnit"
  175. ></el-input>
  176. </template>
  177. </el-table-column>
  178. <el-table-column label="收货单位" min-width="200" align="center">
  179. <template v-slot="scope">
  180. <el-input
  181. :input-style="
  182. scope.row.receivingUnit ? {} : { border: '1px solid red' }
  183. "
  184. size="small"
  185. v-model="scope.row.receivingUnit"
  186. ></el-input>
  187. </template>
  188. </el-table-column>
  189. <el-table-column label="毛重" min-width="120" align="center">
  190. <template v-slot="scope">
  191. <el-input
  192. :input-style="
  193. scope.row.grossWeight ? {} : { border: '1px solid red' }
  194. "
  195. size="small"
  196. v-model="scope.row.grossWeight"
  197. ></el-input>
  198. </template>
  199. </el-table-column>
  200. <el-table-column label="皮重" min-width="120" align="center">
  201. <template v-slot="scope">
  202. <el-input
  203. :input-style="scope.row.tare ? {} : { border: '1px solid red' }"
  204. size="small"
  205. v-model="scope.row.tare"
  206. ></el-input>
  207. </template>
  208. </el-table-column>
  209. <el-table-column label="净重" min-width="120" align="center">
  210. <template v-slot="scope">
  211. <el-input
  212. :input-style="
  213. scope.row.netWeight ? {} : { border: '1px solid red' }
  214. "
  215. size="small"
  216. v-model="scope.row.netWeight"
  217. ></el-input>
  218. </template>
  219. </el-table-column>
  220. <el-table-column label="货船名称" min-width="120" align="center">
  221. <template v-slot="scope">
  222. <el-input size="small" v-model="scope.row.shipName"></el-input>
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="司磅员" min-width="120" align="center">
  226. <template v-slot="scope">
  227. <el-input size="small" v-model="scope.row.weigher"></el-input>
  228. </template>
  229. </el-table-column>
  230. <el-table-column label="查看" min-width="120" align="center">
  231. <template v-slot="scope">
  232. <el-image
  233. style="height: 40px; width: 60px"
  234. fit="contain"
  235. :src="scope.row.viewUrl"
  236. :preview-src-list="ocrImageList"
  237. ></el-image
  238. ></template>
  239. </el-table-column>
  240. </el-table>
  241. </div>
  242. </div>
  243. <div class="df jcfe" v-if="distributeType != -1 && distributeType != 5">
  244. <el-button size="large" type="primary" @click="submitDistribute"
  245. >提交</el-button
  246. >
  247. </div>
  248. </div>
  249. </template>
  250. <script setup>
  251. import { ref, h, reactive, toRefs, onMounted } from "vue";
  252. import { ElNotification, ElMessageBox, ElMessage } from "element-plus";
  253. import store from "../../store";
  254. import router from "../../router";
  255. import md5 from "md5";
  256. import api from "../../apis/fetch";
  257. import { useRoute } from "vue-router";
  258. const route = useRoute();
  259. let fileList = ref([]);
  260. let discPorts = ref([]);
  261. let isCheckAll = ref(false);
  262. let isIndeterminate = ref(false);
  263. let previewList = ref([]);
  264. function checkAll(b) {
  265. isIndeterminate.value = false;
  266. fileList.value.forEach((e) => {
  267. e.checked = b;
  268. });
  269. setRecordIds();
  270. }
  271. function checkItem() {
  272. if (
  273. fileList.value.every((item) => {
  274. return item.checked;
  275. })
  276. ) {
  277. isCheckAll.value = true;
  278. isIndeterminate.value = false;
  279. } else if (
  280. fileList.value.every((item) => {
  281. return !item.checked;
  282. })
  283. ) {
  284. isCheckAll.value = false;
  285. isIndeterminate.value = false;
  286. } else {
  287. isIndeterminate.value = true;
  288. }
  289. setRecordIds();
  290. }
  291. function setRecordIds() {
  292. let arr0 = [];
  293. for (let i of fileList.value) {
  294. if (i.checked) {
  295. checkedPreviewList.value.push(i.viewUrl);
  296. arr0.push(i.id);
  297. }
  298. }
  299. recordIds.value = arr0.join(",");
  300. ocrTruckRecordTableData.value = [];
  301. }
  302. async function getBill() {
  303. let res = await api.getBill({
  304. voyageId: route.query.id,
  305. });
  306. fileList.value = res.data.result;
  307. for (let i of fileList.value || []) {
  308. previewList.value.push(i.viewUrl);
  309. }
  310. }
  311. let distributeType = ref(-1);
  312. let distributePortId = ref(-1);
  313. let distributePoundForm = ref({});
  314. let ocrLoading = ref(false);
  315. let ocrImageList = ref([]);
  316. let checkedPreviewList = ref([]);
  317. let recordIds = ref("");
  318. let ocrTruckRecordTableData = ref([]);
  319. async function ocr() {
  320. ocrLoading.value = true;
  321. ocrImageList.value = [];
  322. let res = await api.ocr({
  323. recordIds: recordIds.value,
  324. });
  325. ocrLoading.value = false;
  326. ocrTruckRecordTableData.value = res.data.result;
  327. for (let i of ocrTruckRecordTableData.value) {
  328. if (i.weighTime) i.weighTime = i.weighTime.substring(0, 10);
  329. ocrImageList.value.push(i.viewUrl);
  330. }
  331. }
  332. async function fail() {
  333. let res = await api.distribute({
  334. voyageId: route.query.id,
  335. recordIds: recordIds.value,
  336. type: 5,
  337. });
  338. console.log(res);
  339. distributeType.value = -1;
  340. recordIds.value = [];
  341. distributePortId.value = -1;
  342. ocrTruckRecordTableData.value = [];
  343. isCheckAll.value = false;
  344. isIndeterminate.value = false;
  345. getBill();
  346. }
  347. async function submitDistribute() {
  348. if (recordIds.value.length == 0) {
  349. ElMessage({
  350. type: "error",
  351. message: "请选择要分配的图片!",
  352. });
  353. return;
  354. }
  355. if (distributeType.value == -1) {
  356. ElMessage({
  357. type: "error",
  358. message: "请选择要分配类型!",
  359. });
  360. return;
  361. }
  362. if (distributePortId.value == -1) {
  363. ElMessage({
  364. type: "error",
  365. message: "请选择要分配的港口!",
  366. });
  367. return;
  368. }
  369. let postData = {};
  370. let type = distributeType.value;
  371. if (2 == type) {
  372. if (
  373. !distributePoundForm.value.dischargeTime ||
  374. !distributePoundForm.value.dischargeTons
  375. ) {
  376. ElMessage({
  377. type: "error",
  378. message: "卸货时间和吨位必填!",
  379. });
  380. return;
  381. }
  382. postData = {
  383. poundBillData: {
  384. ...distributePoundForm.value,
  385. portId: distributePortId.value,
  386. },
  387. };
  388. } else if (4 == type) {
  389. if (!ocrTruckRecordTableData.value.length) {
  390. ElMessage({
  391. type: "error",
  392. message: "请识别装货单!",
  393. });
  394. return;
  395. }
  396. for (let i of ocrTruckRecordTableData.value) {
  397. i.portId = distributePortId.value;
  398. }
  399. postData = { carLoadDatas: ocrTruckRecordTableData.value };
  400. }
  401. console.log(postData, route.query.id, recordIds.value, type);
  402. let res = await api.distribute({
  403. ...postData,
  404. voyageId: route.query.id,
  405. recordIds: recordIds.value,
  406. type,
  407. });
  408. if (res.data.status == 0) {
  409. ElMessage({
  410. type: "success",
  411. message: res.data.msg,
  412. });
  413. } else {
  414. ElMessage({
  415. type: "info",
  416. message: res.data.msg,
  417. });
  418. }
  419. distributeType.value = -1;
  420. recordIds.value = [];
  421. distributePortId.value = -1;
  422. ocrTruckRecordTableData.value = [];
  423. isCheckAll.value = false;
  424. isIndeterminate.value = false;
  425. getBill();
  426. }
  427. onMounted(() => {
  428. discPorts.value = JSON.parse(route.query.discPorts);
  429. getBill();
  430. });
  431. </script>
  432. <style scoped>
  433. </style>