printCarInfo.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <section class="printContent">
  3. <div class="ticket next-ticket">
  4. <div class="flex" style="line-height: 32px">
  5. <div class="flex-1">
  6. 库名:
  7. <JSearchSelect
  8. v-if="!info.destination && info.id"
  9. type="list"
  10. style="width: 160px"
  11. v-model:value="info.typeConfigId"
  12. :options="destinationOptions[ccmNo]"
  13. placeholder="请选择"
  14. allowClear
  15. @change="(v) => handleSelectChange(v, 'destination')"
  16. ref="destinationRef"
  17. />
  18. <span v-else>{{ info.destination }}</span>
  19. <a-button
  20. style="margin-left: 10px"
  21. v-if="!info.outTime && info.id && info.destination"
  22. type="primary"
  23. :loading="btnLoading"
  24. @click="sendCar"
  25. >
  26. 发车
  27. </a-button>
  28. <a-button
  29. style="margin-left: 10px"
  30. v-if="commonPositon.includes(String(carPositon)) && !info.outTime && info.id"
  31. type="primary"
  32. :loading="btnLoading"
  33. @click="updateCcmNo"
  34. >
  35. 变更#{{ info.ccmNo == '5' ? '6' : '5' }}
  36. </a-button>
  37. </div>
  38. <div class="flex-1" style="text-align: center; font-size: 16px">{{ dayjs(info.arrivalTime).format('YYYY 年 MM 月 DD 日 HH 时 mm 分') }}</div>
  39. <div class="flex-1" style="text-align: right; font-size: 16px"></div>
  40. </div>
  41. <a-descriptions layout="vertical" bordered :column="8" size="small">
  42. <a-descriptions-item label="序号">
  43. <div style="min-height: 80px; display: flex; align-items: center; justify-content: center">
  44. <span>{{ info.carAllNum }}</span>
  45. </div>
  46. </a-descriptions-item>
  47. <a-descriptions-item label="车号">
  48. <!-- {{ info.licensePlate }} -->
  49. <JSearchSelect
  50. type="list"
  51. v-if="!info.outTime && info.id"
  52. style="width: 117px"
  53. v-model:value="info.licensePlate"
  54. dict="lg_car"
  55. @change="(v) => handleSelectChange(v, 'licensePlate')"
  56. placeholder="请选择"
  57. allowClear
  58. />
  59. <span v-else>{{ info.licensePlate }}</span>
  60. </a-descriptions-item>
  61. <a-descriptions-item label="牌号">
  62. <JSearchSelect
  63. type="list"
  64. v-if="!info.outTime && info.id"
  65. style="width: 117px"
  66. v-model:value="info.brandNum"
  67. dict="billet_spec"
  68. @change="(v) => handleSelectChange(v, 'brandNum')"
  69. placeholder="请选择"
  70. allowClear
  71. />
  72. <span v-else>
  73. <component :is="renderDictTag(info.brandNum, 'billet_spec')" />
  74. </span>
  75. </a-descriptions-item>
  76. <a-descriptions-item style="position: relative; text-align: left" label="炉号">
  77. <div v-for="item in headDtl" :key="item.heatNo">{{ item.heatNo }} - {{ item.nums }}</div>
  78. <div class="correct" v-if="!info.outTime && info.id && headDtl.length > 0">
  79. <a-button
  80. size="small"
  81. type="primary"
  82. @click="
  83. () => openDetailModal(true, { record: { ...info, typeConfigId: !info.typeConfigId ? '1024' : info.typeConfigId }, isUpdate: true })
  84. "
  85. >
  86. 修正
  87. </a-button>
  88. </div>
  89. </a-descriptions-item>
  90. <a-descriptions-item label="规格">
  91. 170 /
  92. <JSearchSelect
  93. class="size-input"
  94. type="list"
  95. v-if="!info.outTime && info.id"
  96. style="width: 80px; text-align: left"
  97. v-model:value="info.size"
  98. dict="lg_dcgg"
  99. @change="(v) => handleSelectChange(v, 'size')"
  100. placeholder="请选择"
  101. allowClear
  102. />
  103. <span v-else>
  104. {{ info.size }}
  105. </span>
  106. </a-descriptions-item>
  107. <a-descriptions-item label="名称"> 方坯 </a-descriptions-item>
  108. <a-descriptions-item label="支数">
  109. {{ info.amountTotal }}
  110. </a-descriptions-item>
  111. <!-- <a-descriptions-item label="重量(t)">
  112. {{ weight > 0 ? weight.toFixed(3) : 0 }}
  113. </a-descriptions-item> -->
  114. </a-descriptions>
  115. </div>
  116. </section>
  117. <!-- 详情 -->
  118. <correct @register="registerDetailModal" showActionColumn @success="() => getTableList()" />
  119. </template>
  120. <script lang="ts" setup>
  121. import { ref, h, computed } from 'vue';
  122. import dayjs from 'dayjs';
  123. import { listShippingBill, startCar, edit } from '../../shippingBill/shippingBill.api';
  124. import { destinationOptions } from '../../hotDelivery/common.data';
  125. import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
  126. import { useMessage } from '/@/hooks/web/useMessage';
  127. import { render } from '/@/utils/common/renderUtils';
  128. import correct from './correct.vue';
  129. import { useModal } from '/@/components/Modal';
  130. const { createConfirm, createMessage } = useMessage();
  131. // 棒线堆垛明细
  132. const [registerDetailModal, { openModal: openDetailModal }] = useModal();
  133. const emits = defineEmits(['change', 'refresh']);
  134. const props = defineProps({
  135. ccmNo: {
  136. type: [String, Number],
  137. default: '5',
  138. },
  139. api: {
  140. type: Function as PropType<(params: any) => Promise<any>>,
  141. default: listShippingBill,
  142. },
  143. info: {
  144. type: Object,
  145. default: () => {},
  146. },
  147. carPositon: {
  148. type: [Number, String],
  149. default: 1,
  150. },
  151. });
  152. const destinationRef = ref<any>(null);
  153. // const headDtl = ref<any[]>([]);
  154. const weight = ref<number>(0);
  155. const sizeInfo = ref<string[]>([]);
  156. // 共用的车位
  157. const commonPositon = ['2', '4'];
  158. // 渲染字典标签
  159. const renderDictTag = (value: string, dictCode: string) => {
  160. return render.renderDict(value, dictCode);
  161. };
  162. // 获取炉号
  163. // headDtl.value = newArr;
  164. // weight.value = allWeight;
  165. // sizeInfo.value = sizeArr;
  166. const headDtl = computed(() => {
  167. if (!props.info || !props.info.heatNoCountMap) return [];
  168. return Object.keys(props.info.heatNoCountMap).map((item) => {
  169. return { heatNo: item, nums: props.info.heatNoCountMap[item] };
  170. });
  171. });
  172. const getTableList = async () => {
  173. return;
  174. try {
  175. const { id, ccmNo, heatNo, typeConfigId } = props.info;
  176. const data = await props.api({
  177. id,
  178. ccmNo,
  179. heatNo,
  180. typeConfigId: !typeConfigId ? '1024' : typeConfigId,
  181. });
  182. let newArr: any[] = [];
  183. if (Array.isArray(data)) {
  184. newArr = data;
  185. } else {
  186. for (let item in data) {
  187. if (data[item] && data[item].length > 0) {
  188. newArr = newArr.concat(data[item]);
  189. }
  190. }
  191. }
  192. let allWeight = 0;
  193. let sizeArr: string[] = [];
  194. // 数据结果按组批号分组
  195. newArr = newArr.reduce((acc, cur) => {
  196. const index = acc.findIndex((item) => cur.heatNo && item.heatNo === cur.heatNo);
  197. if (index === -1) {
  198. acc.push({
  199. ...cur,
  200. billetNos: [...cur.billetNo.split(',')],
  201. });
  202. } else {
  203. acc[index].billetNos = acc[index].billetNos.concat(cur.billetNo.split(','));
  204. }
  205. if (cur.blankOutput) {
  206. allWeight += Number(cur.blankOutput);
  207. }
  208. if (sizeArr.indexOf(cur.size) === -1) {
  209. sizeArr.push(cur.size);
  210. }
  211. return acc;
  212. }, []);
  213. // headDtl.value = newArr;
  214. weight.value = allWeight;
  215. sizeInfo.value = sizeArr;
  216. } catch (error) {
  217. console.log(error);
  218. } finally {
  219. }
  220. };
  221. const handleSelectChange = (v: any, type: string) => {
  222. emits('change', { value: v, type, carPositon: props.carPositon });
  223. };
  224. // 发车
  225. const btnLoading = ref(false);
  226. const sendCar = async () => {
  227. try {
  228. if (!props.info.destination) {
  229. createMessage.error('请选择库名');
  230. return;
  231. }
  232. if (!props.info.licensePlate) {
  233. createMessage.error('请选择车牌号');
  234. return;
  235. }
  236. createConfirm({
  237. iconType: 'warning',
  238. title: '请确认是否发车?',
  239. onOk: () => {
  240. return startCar({ ...props.info }).then(() => {
  241. emits('refresh');
  242. });
  243. },
  244. });
  245. } catch (error) {
  246. console.log(error);
  247. }
  248. };
  249. // 修改铸机号
  250. const updateCcmNo = async () => {
  251. try {
  252. if (!props.info.id) {
  253. createMessage.error('信息不正确,无法修改铸机号。');
  254. return;
  255. }
  256. createConfirm({
  257. iconType: 'warning',
  258. title: '确认修改',
  259. width: '460px',
  260. content: () => {
  261. return h('div', { style: { fontSize: '16px' } }, [
  262. h('span', null, `是否将`),
  263. h('span', { style: { fontSize: '18px', color: '#d48806' } }, `${props.info.ccmNo}#机 `),
  264. h('span', null, ` 改为 `),
  265. h('span', { style: { fontSize: '18px', color: '#3b5999' } }, ` ${props.info.ccmNo == '5' ? ' 6 ' : ' 5 '}#机`),
  266. h('span', null, `?`),
  267. ]);
  268. },
  269. okText: '确认',
  270. cancelText: '取消',
  271. onOk: () => {
  272. return edit({ ...props.info, ccmNo: props.info.ccmNo == '5' ? '6' : '5' }).then(() => {
  273. emits('refresh');
  274. });
  275. },
  276. });
  277. } catch (error) {
  278. console.log(error);
  279. }
  280. };
  281. defineExpose({
  282. getTableList,
  283. focusDestination: () => {
  284. // destinationRef.value && destinationRef.value.handleAsyncFocus();
  285. },
  286. });
  287. </script>
  288. <style lang="less" scoped>
  289. .printContent {
  290. padding: 10px;
  291. position: relative;
  292. border: 1px solid #c5c5c5;
  293. background: #01396c;
  294. width: 100%;
  295. border-radius: 4px;
  296. color: #fff;
  297. .ant-descriptions {
  298. margin-top: 6px;
  299. margin-bottom: 4px;
  300. }
  301. .correct {
  302. position: absolute;
  303. right: 2px;
  304. top: -32px;
  305. }
  306. :deep(.ant-descriptions-view) {
  307. .ant-descriptions-item-label,
  308. .ant-descriptions-item-content {
  309. border: 1px solid #bfbfbf;
  310. font-size: 16px;
  311. padding: 4px;
  312. text-align: center;
  313. height: 36px;
  314. color: #fff;
  315. }
  316. }
  317. .size-input {
  318. :deep(.ant-select-selector) {
  319. padding: 0 4px;
  320. }
  321. }
  322. }
  323. </style>