index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <div class="storageAndTransportation flex flex-col">
  3. <div class="search-wrapper">
  4. <BasicForm class="search-form" @register="registerForm" @submit="handleSubmit" @reset="handleSubmit">
  5. <template #ccmNo="{ model, field }">
  6. <segmented-select
  7. v-model:value="model[field]"
  8. @change="
  9. () => {
  10. handleSubmit();
  11. }
  12. "
  13. dict="lg_zj"
  14. />
  15. </template>
  16. <template #advanceBefore>
  17. <a-button type="primary" preIcon="ant-design:export-outlined" style="margin-right: 10px" @click="onExportXls"> 导出</a-button>
  18. <a-button type="primary" preIcon="ant-design:export-outlined" style="margin-right: 10px" @click="onExportTicketsXls"> 导出票据</a-button>
  19. </template>
  20. </BasicForm>
  21. </div>
  22. <a-list item-layout="vertical" size="large" :loading="loading" :data-source="listData">
  23. <template #renderItem="{ item, index }">
  24. <a-list-item key="item.heatNo">
  25. <a-list-item-meta>
  26. <template #title>
  27. <span>炉号:{{ item.heatNo }}</span>
  28. <span style="padding: 0 20px"> 总支数:{{ item.heatNoAmount }} </span>
  29. <span> 总重量:{{ item.heatNoWeight }} t </span>
  30. <span style="padding: 0 20px"> 开始时间:{{ item.createTime }} </span>
  31. </template>
  32. <template #avatar>
  33. <a-tag color="#108ee9">{{ index + 1 }}</a-tag>
  34. </template>
  35. </a-list-item-meta>
  36. <div class="flex heat-wrapper">
  37. <div class="items-content flex-1" :style="{ width: 100 / item.content.length + '%' }" v-for="pval in item.content">
  38. <a-card>
  39. <template #title>
  40. <div class="customer-title flex">
  41. <img src="/@/assets/images/send.png" v-if="pval.type === 'line'" alt="" class="heat-img" />
  42. <img src="/@/assets/images/charge.png" v-if="pval.type === 'car'" alt="" class="heat-img" />
  43. <div class="heat-title">
  44. {{ pval.title }} 【{{ pval.type == 'car' ? pval.content['rollChargeDetails'].length : pval.content['rollSendDetails'].length }}
  45. 条记录】
  46. </div>
  47. </div>
  48. </template>
  49. <template v-if="pval.type == 'car'">
  50. <div class="ticket next-ticket" v-for="(sval, i) in pval.content['rollChargeDetails']">
  51. <a-descriptions size="small">
  52. <a-descriptions-item label="库名"> {{ pval.title }} </a-descriptions-item>
  53. <a-descriptions-item> {{ dayjs(sval.createTime).format('YYYY 年 MM 月 DD 日 HH 时 mm 分') }} </a-descriptions-item>
  54. <a-descriptions-item>
  55. <div style="width: 100%; text-align: right">
  56. <a-tag v-if="sval.btype == 1">冷装</a-tag>
  57. <a-tag color="#f50" v-else>热装</a-tag>
  58. </div>
  59. </a-descriptions-item>
  60. </a-descriptions>
  61. <a-descriptions class="ticket-content" layout="vertical" bordered :column="8" size="small">
  62. <a-descriptions-item label="序号">{{ sval.carNum }}</a-descriptions-item>
  63. <a-descriptions-item label="炉号">{{ sval.heatNo }}</a-descriptions-item>
  64. <a-descriptions-item label="车号">{{ sval.licensePlate }}</a-descriptions-item>
  65. <a-descriptions-item label="类型"><component :is="renderDictTag(sval.btype, 'lg_btype')" /></a-descriptions-item>
  66. <a-descriptions-item label="定尺">{{ sval.size }}</a-descriptions-item>
  67. <a-descriptions-item label="牌号"><component :is="renderDictTag(sval.brandNum, 'billet_spec')" /></a-descriptions-item>
  68. <a-descriptions-item label="支数">{{ sval.amount }}</a-descriptions-item>
  69. <a-descriptions-item label="重量">{{ sval.weight }}</a-descriptions-item>
  70. </a-descriptions>
  71. </div>
  72. </template>
  73. <a-table
  74. v-else
  75. class="heat-s-table"
  76. size="small"
  77. :scroll="{ y: 300 }"
  78. :columns="columnLine"
  79. :pagination="false"
  80. :data-source="pval.content['rollSendDetails']"
  81. />
  82. </a-card>
  83. </div>
  84. </div>
  85. </a-list-item>
  86. </template>
  87. </a-list>
  88. </div>
  89. </template>
  90. <script lang="ts" name="storageAndTransportation" setup>
  91. import { onMounted, ref } from 'vue';
  92. //引入依赖
  93. import { useForm, BasicForm, FormSchema } from '/@/components/Form';
  94. import { getStorageCenterInvoicingInfo, exportExcel, exportInvoice } from './storageAndTransportation.api';
  95. import SegmentedSelect from '/@/components/SegmentedSelect/index.vue';
  96. import { isArray } from '/@/utils/is';
  97. import dayjs from 'dayjs';
  98. import { render } from '/@/utils/common/renderUtils';
  99. import { useMethods } from '/@/hooks/system/useMethods';
  100. import { useMessage } from '/@/hooks/web/useMessage';
  101. const { createMessage } = useMessage();
  102. //导入导出方法
  103. const { handleExportXlsx } = useMethods();
  104. // 渲染字典标签
  105. const renderDictTag = (value: string, dictCode: string) => {
  106. return render.renderDict(value, dictCode);
  107. };
  108. //自定义表单字段
  109. const formSchemas: FormSchema[] = [
  110. {
  111. field: 'ccmNo',
  112. label: '铸机',
  113. component: 'Input',
  114. defaultValue: '5',
  115. componentProps: {
  116. dictCode: 'lg_zj',
  117. },
  118. colProps: { span: 6 },
  119. slot: 'ccmNo',
  120. },
  121. {
  122. label: '炉号',
  123. field: 'heatsCode',
  124. component: 'Input',
  125. },
  126. {
  127. label: '班组',
  128. field: 'shiftGroup',
  129. component: 'JDictSelectTag',
  130. componentProps: {
  131. dictCode: 'lg_bz',
  132. },
  133. },
  134. {
  135. label: '班别',
  136. field: 'shift',
  137. component: 'JDictSelectTag',
  138. componentProps: {
  139. dictCode: 'lg_bb',
  140. },
  141. },
  142. // {
  143. // label: '炉次日期',
  144. // field: 'createTime',
  145. // component: 'RangePicker',
  146. // componentProps: {
  147. // valueFormat: 'YYYY-MM-DD',
  148. // },
  149. // },
  150. {
  151. label: '装运日期',
  152. field: 'storageTime',
  153. component: 'RangePicker',
  154. componentProps: {
  155. showTime: true,
  156. valueFormat: 'YYYY-MM-DD HH:mm:ss',
  157. },
  158. },
  159. {
  160. label: '票据打印时间',
  161. field: 'receipt',
  162. component: 'DatePicker',
  163. componentProps: {
  164. valueFormat: 'YYYY-MM-DD',
  165. },
  166. },
  167. ];
  168. /**
  169. * BasicForm绑定注册;
  170. */
  171. const [registerForm, { getFieldsValue }] = useForm({
  172. //注册表单列
  173. schemas: formSchemas,
  174. //是否显示展开收起按钮,默认false
  175. showAdvancedButton: true,
  176. //超过指定行数折叠,默认3行
  177. autoAdvancedCol: 3,
  178. //折叠时默认显示行数,默认1行
  179. alwaysShowLines: 3,
  180. //将表单内时间区域的值映射成 2个字段, 'YYYY-MM-DD'日期格式化
  181. fieldMapToTime: [
  182. ['createTime', ['createTime_begin', 'createTime_end'], 'YYYY-MM-DD HH:mm:ss'],
  183. ['storageTime', ['storageTime_begin', 'storageTime_end'], 'YYYY-MM-DD HH:mm:ss'],
  184. ],
  185. //每列占比,默认一行为24
  186. baseColProps: { span: 6 },
  187. });
  188. /**
  189. * 点击提交按钮的value值
  190. * @param values
  191. */
  192. function handleSubmit() {
  193. getList();
  194. }
  195. const listData = ref<Record<string, any>>([]);
  196. const loading = ref(false);
  197. const columnLine = [
  198. { title: '日期', dataIndex: 'createTime' },
  199. { title: '定尺', dataIndex: 'size' },
  200. { title: '规格', dataIndex: 'spec' },
  201. { title: '支数', dataIndex: 'amount' },
  202. { title: '重量/t', dataIndex: 'weight' },
  203. ];
  204. const getList = async () => {
  205. try {
  206. loading.value = true;
  207. const values = getFieldsValue();
  208. if (!values.ccmNo) {
  209. values.ccmNo = '5';
  210. }
  211. console.log('values', values);
  212. const params = Object.assign({}, values, {
  213. createTimeBegin: values.createTime_begin,
  214. createTimeEnd: values.createTime_end,
  215. storageTimeBegin: values.storageTime_begin,
  216. storageTimeEnd: values.storageTime_end,
  217. });
  218. const records = await getStorageCenterInvoicingInfo(params);
  219. if (records && isArray(records)) {
  220. const list = records.map((item: any) => {
  221. let content: any[] = [];
  222. const {
  223. heatNoDetails,
  224. storageCenterHeatNoInvoicing: {
  225. rollClubOneDetails,
  226. rollClubTwoDetails,
  227. rollClubThreeDetails,
  228. rollHeightDetails,
  229. rollOutShippDetails,
  230. rollDeputyDetails,
  231. },
  232. } = item;
  233. if (rollClubOneDetails) {
  234. content.push({
  235. title: '棒一',
  236. type: 'line',
  237. content: rollClubOneDetails,
  238. });
  239. }
  240. if (rollClubTwoDetails) {
  241. content.push({
  242. title: '棒二',
  243. type: 'car',
  244. content: rollClubTwoDetails,
  245. });
  246. }
  247. if (rollClubThreeDetails) {
  248. content.push({
  249. title: '棒三',
  250. type: 'car',
  251. content: rollClubThreeDetails,
  252. });
  253. }
  254. if (rollDeputyDetails) {
  255. content.push({
  256. title: '付跨',
  257. type: 'car',
  258. content: rollDeputyDetails,
  259. });
  260. }
  261. if (rollOutShippDetails) {
  262. content.push({
  263. title: '上若',
  264. type: 'car',
  265. content: rollOutShippDetails,
  266. });
  267. }
  268. if (rollHeightDetails) {
  269. content.push({
  270. title: '高线',
  271. type: 'line',
  272. content: rollHeightDetails,
  273. });
  274. }
  275. return {
  276. ...heatNoDetails[0],
  277. content,
  278. };
  279. });
  280. listData.value = list;
  281. }
  282. loading.value = false;
  283. } catch (error) {
  284. console.error(error);
  285. loading.value = false;
  286. }
  287. };
  288. // 导出
  289. const onExportXls = () => {
  290. const values = getFieldsValue();
  291. if (!values.storageTime_begin) {
  292. createMessage.error('请选择装运日期');
  293. return;
  294. }
  295. if (!values.ccmNo) {
  296. values.ccmNo = '5';
  297. }
  298. const params = Object.assign({}, values);
  299. let queryParams = Object.keys(params)
  300. .filter((v) => params[v])
  301. .map((key) => {
  302. if (key === 'createTime_begin') {
  303. return `createTimeBegin=${params[key]}`;
  304. }
  305. if (key === 'createTime_end') {
  306. return `createTimeEnd=${params[key]}`;
  307. }
  308. if (key === 'storageTime_begin') {
  309. return `storageTimeBegin=${params[key]}`;
  310. }
  311. if (key === 'storageTime_end') {
  312. return `storageTimeEnd=${params[key]}`;
  313. }
  314. return `${key}=${params[key]}`;
  315. });
  316. return handleExportXlsx('储运中心', exportExcel() + (queryParams.length > 0 ? '?' + queryParams.join('&') : ''));
  317. };
  318. const onExportTicketsXls = () => {
  319. const values = getFieldsValue();
  320. console.log('values', values);
  321. let queryParams = Object.keys(values)
  322. .filter((v) => values[v])
  323. .map((key) => {
  324. return `${key}=${values[key]}`;
  325. });
  326. if (!values['receipt']) {
  327. queryParams.push(`arrivalTime=${dayjs().format('YYYY-MM-DD 00:00:00')}`);
  328. queryParams.push(`createTime=${dayjs().format('YYYY-MM-DD 23:59:59')}`);
  329. } else {
  330. queryParams.push(`arrivalTime=${values['receipt']} 00:00:00`);
  331. queryParams.push(`createTime=${values['receipt']} 23:59:59`);
  332. }
  333. return handleExportXlsx('储运票据', exportInvoice() + (queryParams.length > 0 ? '?' + queryParams.join('&') : ''));
  334. };
  335. onMounted(() => {
  336. getList();
  337. });
  338. </script>
  339. <style lang="less" scoped>
  340. .storageAndTransportation {
  341. margin: 10px;
  342. .search-wrapper {
  343. margin-bottom: 10px;
  344. background-color: #fff;
  345. padding-top: 30px;
  346. .search-form {
  347. :deep(.btnArea) {
  348. .ant-form-item-row {
  349. width: 100%;
  350. justify-content: flex-end;
  351. }
  352. }
  353. }
  354. }
  355. .ant-list {
  356. background-color: #fff;
  357. padding: 10px;
  358. }
  359. .heat-wrapper {
  360. gap: 10px;
  361. }
  362. .items-content {
  363. flex-shrink: 0;
  364. }
  365. .customer-title {
  366. line-height: 32px;
  367. }
  368. .heat-img {
  369. width: 32px;
  370. height: 32px;
  371. }
  372. .heat-title {
  373. margin-left: 8px;
  374. margin-right: 60px;
  375. font-weight: 400;
  376. font-size: 14px;
  377. color: #000000;
  378. }
  379. .ant-card {
  380. width: 100%;
  381. height: 100%;
  382. overflow: hidden;
  383. :deep(.ant-card-body) {
  384. padding: 10px;
  385. display: flex;
  386. overflow: auto;
  387. &::after,
  388. &::before {
  389. display: none;
  390. }
  391. }
  392. }
  393. /* 基础票据样式 */
  394. .ticket {
  395. width: 672px;
  396. background: #fff;
  397. border-radius: 8px;
  398. box-shadow: 5px 0px 6px 2px rgba(0, 0, 0, 0.25);
  399. padding: 10px;
  400. position: relative;
  401. border-left: 4px solid #ddd;
  402. transition: transform 0.2s;
  403. margin-right: 10px;
  404. flex-shrink: 0;
  405. &:last-child {
  406. margin-right: 0;
  407. }
  408. }
  409. /* 下一个票据的特殊样式 */
  410. .next-ticket {
  411. border-left-color: #0958d9; /* 左侧高亮蓝色边框 */
  412. background: #f8f9fa; /* 浅灰色背景 */
  413. }
  414. }
  415. </style>