invoiceDialog.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <ele-modal
  3. custom-class="ele-dialog-form long-dialog-form"
  4. :centered="true"
  5. :visible.sync="addRepairNotesDialog"
  6. title="发货单"
  7. :close-on-click-modal="false"
  8. width="85%"
  9. append-to-body
  10. @close="handleClose"
  11. :maxable="true"
  12. >
  13. <div class="main_container">
  14. <el-form
  15. :model="searchForm"
  16. label-width="120px"
  17. @keyup.enter.native="onSearch"
  18. @submit.native.prevent
  19. >
  20. <el-row>
  21. <el-col :span="8">
  22. <el-form-item label="发货单编码:">
  23. <el-input
  24. style="width: 100%"
  25. type="text"
  26. clearable
  27. placeholder="请输入"
  28. v-model="searchForm.docNo"
  29. ></el-input>
  30. </el-form-item>
  31. </el-col>
  32. <el-col :span="8">
  33. <el-form-item label="销售订单编码:">
  34. <el-input
  35. style="width: 100%"
  36. type="text"
  37. clearable
  38. placeholder="请输入"
  39. v-model="searchForm.orderNo"
  40. ></el-input>
  41. </el-form-item>
  42. </el-col>
  43. <el-col :span="8">
  44. <el-form-item label="客户名称:">
  45. <el-input
  46. style="width: 100%"
  47. type="text"
  48. clearable
  49. placeholder="请输入"
  50. v-model="searchForm.contactName"
  51. ></el-input>
  52. </el-form-item>
  53. </el-col>
  54. <el-col :span="8">
  55. <el-form-item label="创建时间:">
  56. <el-date-picker
  57. style="width: 100%"
  58. v-model="searchForm.time"
  59. type="datetimerange"
  60. start-placeholder="开始日期"
  61. end-placeholder="结束日期"
  62. :default-time="['00:00:00']"
  63. value-format="yyyy-MM-dd HH:mm:ss"
  64. ></el-date-picker>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="16">
  68. <el-form-item>
  69. <el-button
  70. size="small"
  71. type="primary"
  72. icon="el-icon-search"
  73. class="ele-btn-icon"
  74. @click="onSearch"
  75. >查询</el-button
  76. >
  77. <el-button
  78. @click="reset"
  79. icon="el-icon-refresh"
  80. class="ele-btn-icon"
  81. size="medium"
  82. >重置</el-button
  83. >
  84. <slot></slot>
  85. </el-form-item>
  86. </el-col>
  87. </el-row>
  88. </el-form>
  89. <headerTitle title="发货单" style="margin-top: 8px"></headerTitle>
  90. <ele-pro-table
  91. ref="tableRef2"
  92. :columns="columns"
  93. :datasource="datasource"
  94. tool-class="ele-toolbar-form"
  95. :initLoad="false"
  96. height="300px"
  97. @cell-click="rowClick"
  98. ></ele-pro-table>
  99. <headerTitle title="物品明细" style="margin-top: 8px"></headerTitle>
  100. <ele-pro-table
  101. ref="tableRef3"
  102. :columns="columnsPro"
  103. :datasource="packingList"
  104. :need-page="false"
  105. tool-class="ele-toolbar-form"
  106. :selection.sync="selection"
  107. height="400px"
  108. ></ele-pro-table>
  109. </div>
  110. <div slot="footer" class="footer">
  111. <el-button type="primary" @click="submitAdd">确认</el-button>
  112. <el-button @click="handleClose">取消</el-button>
  113. </div>
  114. </ele-modal>
  115. </template>
  116. <script>
  117. import { parameterGetByCode } from '@/api/main';
  118. import {
  119. getSendTableList,
  120. getSendSaleOrderrecordDetailSplit
  121. } from '@/api/saleManage/saleordersendrecord';
  122. import { reviewStatus } from '@/enum/dict';
  123. import { lbjtList } from '@/enum/dict.js';
  124. import { getInfoBySourceBizNoAll } from '@/api/wms';
  125. const dayjs = require('dayjs');
  126. export default {
  127. props: {
  128. contractBookType: {
  129. //合同类型 1销售 2采购
  130. type: [String, Number],
  131. default: 1
  132. }
  133. },
  134. components: {},
  135. data() {
  136. return {
  137. addRepairNotesDialog: false,
  138. rowClickData: {},
  139. selection: [],
  140. packingList: [],
  141. columns: [
  142. {
  143. columnKey: 'index',
  144. label: '序号',
  145. type: 'index',
  146. width: 55,
  147. align: 'center',
  148. showOverflowTooltip: true
  149. },
  150. {
  151. prop: 'docNo',
  152. label: '发货单编码',
  153. sortable: true,
  154. align: 'center',
  155. slot: 'docNo',
  156. showOverflowTooltip: true,
  157. minWidth: 120
  158. },
  159. {
  160. prop: 'orderNo',
  161. label: '销售订单编码',
  162. sortable: true,
  163. align: 'center',
  164. slot: 'orderNo',
  165. showOverflowTooltip: true,
  166. minWidth: 120
  167. },
  168. {
  169. prop: 'contactName',
  170. label: '客户名称',
  171. align: 'center',
  172. showOverflowTooltip: true,
  173. minWidth: 120
  174. },
  175. {
  176. prop: 'replied',
  177. label: '是否回执',
  178. align: 'center',
  179. showOverflowTooltip: true,
  180. minWidth: 120,
  181. formatter: (_row, _column, cellValue) => {
  182. return _row.replied == 1 ? '是' : '否';
  183. }
  184. },
  185. {
  186. prop: 'reviewStatus',
  187. label: '状态',
  188. align: 'center',
  189. showOverflowTooltip: true,
  190. minWidth: 120,
  191. formatter: (_row, _column, cellValue) => {
  192. return reviewStatus[_row.reviewStatus];
  193. }
  194. },
  195. {
  196. prop: 'createTime',
  197. label: '创建时间',
  198. align: 'center',
  199. showOverflowTooltip: true,
  200. minWidth: 120
  201. }
  202. ],
  203. columnsPro: [
  204. {
  205. width: 45,
  206. type: 'selection',
  207. columnKey: 'selection',
  208. align: 'center'
  209. },
  210. {
  211. columnKey: 'index',
  212. label: '序号',
  213. type: 'index',
  214. width: 55,
  215. align: 'center',
  216. showOverflowTooltip: true
  217. },
  218. {
  219. prop: 'productCategoryName',
  220. label: '类型',
  221. align: 'center',
  222. showOverflowTooltip: true
  223. },
  224. {
  225. prop: 'categoryCode',
  226. label: '编码',
  227. align: 'center',
  228. showOverflowTooltip: true
  229. },
  230. {
  231. prop: 'categoryName',
  232. label: '名称',
  233. align: 'center',
  234. showOverflowTooltip: true
  235. },
  236. {
  237. prop: 'productBrand',
  238. label: '牌号',
  239. align: 'center',
  240. showOverflowTooltip: true
  241. },
  242. {
  243. prop: 'categoryModel',
  244. label: '型号',
  245. align: 'center',
  246. showOverflowTooltip: true
  247. },
  248. {
  249. prop: 'packingSpecification',
  250. label: '规格',
  251. align: 'center',
  252. showOverflowTooltip: true
  253. },
  254. {
  255. prop: 'batchNo',
  256. label: '批次号',
  257. align: 'center',
  258. showOverflowTooltip: true
  259. },
  260. {
  261. prop: 'measureQuantity',
  262. label: '计量数量',
  263. align: 'center',
  264. showOverflowTooltip: true
  265. },
  266. {
  267. prop: 'singlePrice',
  268. label: '单价(元)',
  269. align: 'center',
  270. showOverflowTooltip: true
  271. },
  272. {
  273. prop: 'barcodes',
  274. label: '发货条码/车架号',
  275. align: 'center',
  276. showOverflowTooltip: true
  277. }
  278. ],
  279. contactId: '',
  280. goodsShow: false,
  281. searchForm: {}
  282. };
  283. },
  284. created() {},
  285. methods: {
  286. // 初始化数据(父组件调用)
  287. open(data, obj) {
  288. this.contactId = data;
  289. this.addRepairNotesDialog = true;
  290. // 数据回显 ***
  291. this.rowClickData.id = obj.orderId;
  292. this.rowClickData.docNo = obj.orderCode;
  293. this.packingList = JSON.parse(JSON.stringify(obj.tableList));
  294. this.$nextTick(() => {
  295. this.packingList.forEach((row) => {
  296. this.$refs.tableRef3.toggleRowSelection(row);
  297. });
  298. this.reload();
  299. });
  300. },
  301. datasource({ page, limit, where, order }) {
  302. return getSendTableList({
  303. pageNum: page,
  304. size: limit,
  305. ...where
  306. });
  307. },
  308. onSearch() {
  309. let data = JSON.parse(JSON.stringify(this.searchForm));
  310. if (data.time?.length > 0) {
  311. data.createTimeStart = data.time[0];
  312. data.createTimeEnd = data.time[1];
  313. }
  314. delete data.time;
  315. this.reload(data);
  316. },
  317. reset() {
  318. this.searchForm = {
  319. docNo: '',
  320. orderNo: '',
  321. contactName: '',
  322. time: []
  323. };
  324. this.reload({});
  325. },
  326. reload(where) {
  327. where = {
  328. ...where,
  329. // contractId: this.contractId,
  330. contactId: this.contactId,
  331. reviewStatus: 2
  332. };
  333. this.$refs.tableRef2.reload({ page: 1, where });
  334. },
  335. async rowClick(row) {
  336. this.rowClickData = row;
  337. let params = {
  338. code: 'after_sales_product_list_source'
  339. };
  340. const res = await parameterGetByCode(params);
  341. if (res.value == '1') {
  342. this.getInfo(row);
  343. } else {
  344. this._getInfo(row.docNo);
  345. }
  346. },
  347. handleClose() {
  348. this.addRepairNotesDialog = false;
  349. },
  350. submitAdd() {
  351. if (!this.selection.length) {
  352. return this.$message.warning('请至少选择一条数据');
  353. }
  354. if (this.selection.length > 1) {
  355. return this.$message.warning('只能选择一条物品明细数据');
  356. }
  357. this.$emit('changeParent', {
  358. orderCode: this.rowClickData.docNo,
  359. orderId: this.rowClickData.id,
  360. tableList: this.selection
  361. });
  362. this.handleClose();
  363. },
  364. async getInfo(row) {
  365. const res = await getSendSaleOrderrecordDetailSplit(row.id);
  366. let list = res.productList.map((el) => {
  367. el.categoryCode = el.productCode;
  368. el.categoryName = el.productName;
  369. el.categoryModel = el.modelType;
  370. el.measureQuantity = el.totalCount;
  371. el.barcodes = el.carCode;
  372. el.packingSpecification = el.specification;
  373. el.shipmentDate = row.createTime || null;
  374. (el.guaranteePeriodDeadline = this.getTime(row.createTime)[0]),
  375. (el.warrantyStatus = this.getTime(row.createTime)[1]);
  376. return el;
  377. });
  378. this.packingList = list;
  379. },
  380. async _getInfo(sourceBizNo) {
  381. const dataArray = await getInfoBySourceBizNoAll(sourceBizNo);
  382. let res = {};
  383. if (dataArray && dataArray.length > 0) {
  384. res = JSON.parse(JSON.stringify(dataArray[0]));
  385. res['outInDetailList'] = [];
  386. dataArray.forEach((item) => {
  387. item.outInDetailList.forEach((val) => {
  388. res['outInDetailList'].push(val);
  389. });
  390. });
  391. }
  392. this.init(res);
  393. },
  394. init(res) {
  395. this.infoData = res;
  396. this.productList = res?.outInDetailList?.map(
  397. (productItem, productIndex) => {
  398. return {
  399. ...productItem,
  400. outInDetailRecordRequestList:
  401. productItem.outInDetailRecordRequestList.map((packingItem) => {
  402. return {
  403. ...packingItem,
  404. categoryName: productItem.categoryName,
  405. categoryCode: productItem.categoryCode,
  406. categoryModel: productItem.categoryModel,
  407. produceTime: packingItem.produceTime || null,
  408. shipmentDate: res.createTime || null,
  409. guaranteePeriodDeadline: this.getTime(res.createTime)[0],
  410. warrantyStatus: this.getTime(res.createTime)[1]
  411. };
  412. })
  413. };
  414. }
  415. );
  416. // 获取包装维度数据
  417. const arr = [];
  418. for (const key in this.productList) {
  419. for (const k in this.productList[key].outInDetailRecordRequestList) {
  420. arr.push({
  421. ...this.productList[key].outInDetailRecordRequestList[k]
  422. });
  423. }
  424. }
  425. this.packingList = arr;
  426. },
  427. getTime(createTime) {
  428. let date = new Date(createTime);
  429. date.setMonth(date.getMonth() + 13); // 月份加13月
  430. let time = dayjs(date).format('YYYY-MM-DD HH:mm:ss');
  431. let warrantyStatus =
  432. new Date(time).getTime() > new Date().getTime() ? 0 : 1;
  433. return [time, warrantyStatus];
  434. }
  435. }
  436. };
  437. </script>
  438. <style lang="scss" scoped></style>