shipped.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525
  1. <template>
  2. <div class="container">
  3. <en-table-layout
  4. :tableData="tableData.data"
  5. :loading="loading"
  6. >
  7. <div slot="toolbar" class="inner-toolbar">
  8. <div v-if="boolFounder || permissions.filter(p => p === 'pjOrderShip').length > 0" class="toolbar-btns">
  9. <el-button type="primary" @click="dialogVisible = true">添加</el-button>
  10. <el-button type="primary" @click="handlePrint">打印签收单</el-button>
  11. </div>
  12. </div>
  13. <template slot="table-columns">
  14. <el-table-column label="收货单" width="130">
  15. <template slot-scope="scope">
  16. <div class="goods-info">
  17. <div class="goods-image" style="margin: 0 20px;" @click="handlePictureCardPreview(scope.row.shipped_url)">
  18. <el-image :src="scope.row.shipped_url" fit="cover"></el-image>
  19. </div>
  20. </div>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="发货人" prop="shipped_user" sortable width="170"></el-table-column>
  24. <el-table-column label="发货时间" :formatter="MixinUnixToDate" prop="shipped_time" sortable width="170"></el-table-column>
  25. <el-table-column label="备注" prop="remark" show-overflow-tooltip min-width="180"></el-table-column>
  26. </template>
  27. <el-pagination
  28. v-if="tableData"
  29. slot="pagination"
  30. @size-change="handlePageSizeChange"
  31. @current-change="handlePageCurrentChange"
  32. :current-page="tableData.page_no"
  33. :page-sizes="[20, 50, 100]"
  34. :page-size="tableData.page_size"
  35. layout="total, sizes, prev, pager, next, jumper"
  36. :total="tableData.data_total">
  37. </el-pagination>
  38. </en-table-layout>
  39. <el-dialog title="添加" :visible.sync="dialogVisible">
  40. <el-form :model="addModel">
  41. <el-form-item label="发货时间" prop="shipped_time">
  42. <el-date-picker
  43. v-model="addModel.shipped_time"
  44. type="datetime"
  45. placeholder="请选择时间">
  46. </el-date-picker>
  47. </el-form-item>
  48. <el-form-item label="备注:" class="description">
  49. <el-input type="textarea" rows="3" placeholder="备注,最大150字" maxlength="150" show-word-limit v-model="addModel.remark"></el-input>
  50. </el-form-item>
  51. <el-form-item label="发货单">
  52. <el-upload class="avatar-uploader"
  53. :action="`${MixinUploadApi}/uploadFile?scene=pjshipped`"
  54. :on-success="uploadSuccess"
  55. :before-upload="handleUploadBefore"
  56. :multiple="false"
  57. :limit="1"
  58. >
  59. <el-button size="small" type="primary" icon="el-icon-plus avatar-uploader-icon">点击上传</el-button>
  60. <div slot="tip" class="el-upload__tip">只能上传图片,不超过3M</div>
  61. </el-upload>
  62. <span>{{addModel.shipped_url}}</span>
  63. </el-form-item>
  64. </el-form>
  65. <div slot="footer" class="dialog-footer">
  66. <el-button type="primary" @click="handleAdd">确定</el-button>
  67. </div>
  68. </el-dialog>
  69. <!-- 添加打印选择对话框 -->
  70. <el-dialog title="选择打印项目" :visible.sync="printDialogVisible" width="80%">
  71. <el-table
  72. :data="orderItems"
  73. @selection-change="handleSelectionChange"
  74. border>
  75. <el-table-column
  76. type="selection"
  77. width="55">
  78. </el-table-column>
  79. <el-table-column
  80. prop="name"
  81. label="商品名称"
  82. min-width="200">
  83. </el-table-column>
  84. <el-table-column
  85. prop="code"
  86. label="型号"
  87. min-width="150">
  88. </el-table-column>
  89. <el-table-column
  90. prop="qty"
  91. label="数量"
  92. width="100">
  93. </el-table-column>
  94. <el-table-column
  95. label="本次发货数量"
  96. width="150">
  97. <template slot-scope="scope">
  98. <el-input-number
  99. v-model="scope.row.printQty"
  100. :min="1"
  101. :max="scope.row.qty"
  102. size="small"
  103. controls-position="right"
  104. @change="handleQtyChange(scope.row)">
  105. </el-input-number>
  106. </template>
  107. </el-table-column>
  108. <el-table-column
  109. label="备注"
  110. min-width="250">
  111. <template slot-scope="scope">
  112. <el-input
  113. type="textarea"
  114. :rows="2"
  115. placeholder="请输入备注"
  116. v-model="scope.row.printRemark"
  117. resize="none">
  118. </el-input>
  119. </template>
  120. </el-table-column>
  121. </el-table>
  122. <div style="margin-top: 20px; padding: 0 20px;">
  123. <el-form :model="printForm" label-width="100px">
  124. <el-form-item label="出库时间">
  125. <el-date-picker
  126. v-model="printForm.shipped_time"
  127. type="date"
  128. placeholder="选择日期"
  129. value-format="yyyy-MM-dd"
  130. style="width: 200px;">
  131. </el-date-picker>
  132. </el-form-item>
  133. <el-form-item label="收货地址">
  134. <el-input
  135. type="textarea"
  136. :rows="2"
  137. placeholder="请输入收货地址"
  138. v-model="printForm.address"
  139. style="width: 100%;">
  140. </el-input>
  141. </el-form-item>
  142. </el-form>
  143. </div>
  144. <div slot="footer" class="dialog-footer">
  145. <el-button @click="printDialogVisible = false">取 消</el-button>
  146. <el-button type="primary" @click="handlePrintConfirm">确认打印</el-button>
  147. </div>
  148. </el-dialog>
  149. <el-dialog :visible.sync="dialogImage">
  150. <img width="100%" :src="dialogImageUrl" alt="">
  151. </el-dialog>
  152. <div id="printContent" style="display: none;">
  153. <div style="position: relative; margin-bottom: 10px;">
  154. <div style="position: absolute; top: 0; left: 0;">
  155. <img src="../../assets/logo_images/logo-javashop-rectangle-light.png" style="width: 150px; height: auto;" />
  156. </div>
  157. <div style="text-align: center;">
  158. <h2 style="margin: 3px 0;">深圳市维鼎康联信息技术有限公司</h2>
  159. <h3 style="margin: 3px 0;">签收单</h3>
  160. </div>
  161. </div>
  162. <div style="margin-bottom: 10px;">
  163. <div style="display: flex; justify-content: space-between; margin-bottom: 5px;">
  164. <div>项目名称:{{ orderInfo.name || '未填写' }}</div>
  165. <div>出库时间:{{ printForm.shipped_time || '未填写' }}</div>
  166. </div>
  167. <div>收货地址:{{ printForm.address || '未填写' }}</div>
  168. </div>
  169. <table border="1" cellspacing="0" cellpadding="2" style="width: 100%; border-collapse: collapse;">
  170. <thead>
  171. <tr>
  172. <th>序号</th>
  173. <th>商品名称</th>
  174. <th>型号</th>
  175. <th>数量</th>
  176. <th>备注</th>
  177. </tr>
  178. </thead>
  179. <tbody>
  180. <tr v-for="(item, index) in selectedItems" :key="index">
  181. <td>{{ index + 1 }}</td>
  182. <td>{{ item.name }}</td>
  183. <td>{{ item.code }}</td>
  184. <td>{{ item.printQty }}</td>
  185. <td style="max-width: 200px; word-break: break-all;">{{ item.printRemark || '无' }}</td>
  186. </tr>
  187. <tr v-for="index in (7 - selectedItems.length)" :key="'empty-' + index">
  188. <td>{{ selectedItems.length + index }}</td>
  189. <td></td>
  190. <td></td>
  191. <td></td>
  192. <td></td>
  193. </tr>
  194. </tbody>
  195. </table>
  196. <div style="margin-top: 10px; line-height: 1.5;">
  197. <p style="margin: 3px 0;">如对以上货品名规格,数量验收无误,请签字或盖章回传给我们。</p>
  198. <p style="margin: 3px 0;">如有异议,请立刻联系我司,自货物签收之日起,三日内未收到任何异议,视为品名数量无误。</p>
  199. <div style="margin-top: 10px; text-align: right;">
  200. <div style="display: flex; justify-content: flex-end; align-items: center;">
  201. <span style="margin-right: 20px;">收货单位及经手人(盖章):_________________</span>
  202. <span>签收日期:_________________</span>
  203. </div>
  204. </div>
  205. </div>
  206. <div style="margin-top: 15px;">
  207. <div style="display: flex; justify-content: center; margin-bottom: 5px;">
  208. <div style="width: 33.33%; text-align: left;">送货负责:{{ adminUser.realname }}</div>
  209. <div style="width: 33.33%; text-align: left;">下单:{{ orderInfo.sales || '未填写' }}</div>
  210. <div style="width: 33.33%; text-align: left;">电话:0755-83204332</div>
  211. </div>
  212. <div style="display: flex; justify-content: center;">
  213. <div style="width: 33.33%; text-align: left;">第一联(白):存根</div>
  214. <div style="width: 33.33%; text-align: left;">第二联(红):客户签收单</div>
  215. <div style="width: 33.33%; text-align: left;">第三联(黄):客户</div>
  216. </div>
  217. </div>
  218. </div>
  219. </div>
  220. </template>
  221. <script>
  222. import * as API_Shipped from '@/api/pjShipped'
  223. import * as API_OrderItems from '@/api/pjOrderItems'
  224. import * as API_Order from '@/api/pjOrder'
  225. import Storage from '../../utils/storage'
  226. export default {
  227. name: 'pjRemarkList',
  228. props: {
  229. orderNo: {
  230. type: String,
  231. value: ''
  232. }
  233. },
  234. data() {
  235. return {
  236. boolFounder: JSON.parse(Storage.getItem('admin_user')).founder === 1,
  237. permissions: [],
  238. adminUser: JSON.parse(Storage.getItem('admin_user')),
  239. /** 列表loading状态 */
  240. loading: false,
  241. /** 列表参数 */
  242. params: {
  243. page_no: 1,
  244. page_size: 20,
  245. sort: 'id',
  246. dir: 'desc'
  247. },
  248. /** 列表数据 */
  249. tableData: '',
  250. dialogVisible: false,
  251. printDialogVisible: false,
  252. selectedItems: [],
  253. addModel: {},
  254. dialogImage: false,
  255. dialogImageUrl: '',
  256. orderItems: [],
  257. orderInfo: {},
  258. printForm: {
  259. shipped_time: '',
  260. address: ''
  261. }
  262. }
  263. },
  264. mounted() {
  265. if (!this.boolFounder) {
  266. this.permissions = JSON.parse(Storage.getItem('permissions'))
  267. }
  268. this.GET_List()
  269. },
  270. // watch: {
  271. // orderNo(val) {
  272. // if (val) {
  273. // this.GET_List()
  274. // }
  275. // }
  276. // },
  277. methods: {
  278. /** 分页大小发生改变 */
  279. handlePageSizeChange(size) {
  280. this.params.page_size = size
  281. this.GET_List()
  282. },
  283. /** 分页页数发生改变 */
  284. handlePageCurrentChange(page) {
  285. this.params.page_no = page
  286. this.GET_List()
  287. },
  288. GET_List() {
  289. this.loading = true
  290. this.params.fixedCondition = " order_no='" + this.orderNo + "'"
  291. API_Shipped.getList(this.params).then(response => {
  292. this.loading = false
  293. this.tableData = response
  294. this.getOrderItems()
  295. }).catch(() => (this.loading = false))
  296. },
  297. getOrderItems() {
  298. const params = {
  299. page_no: 1,
  300. page_size: 1000,
  301. fixedCondition: "order_no='" + this.orderNo + "'"
  302. }
  303. API_OrderItems.getList(params).then(response => {
  304. this.orderItems = response.data
  305. this.getOrderInfo()
  306. })
  307. },
  308. getOrderInfo() {
  309. const params = {
  310. page_no: 1,
  311. page_size: 1,
  312. fixedCondition: "order_no='" + this.orderNo + "'"
  313. }
  314. API_Order.getList(params).then(response => {
  315. if (response.data && response.data.length > 0) {
  316. this.orderInfo = response.data[0]
  317. }
  318. })
  319. },
  320. handlePrint() {
  321. // 初始化打印数据
  322. const items = this.orderItems.map(item => ({
  323. ...item,
  324. printQty: Number(item.qty),
  325. printRemark: item.remark || ''
  326. }))
  327. this.orderItems = items
  328. // 初始化打印表单数据
  329. const today = new Date()
  330. const year = today.getFullYear()
  331. const month = String(today.getMonth() + 1).padStart(2, '0')
  332. const day = String(today.getDate()).padStart(2, '0')
  333. this.printForm = {
  334. shipped_time: `${year}-${month}-${day}`,
  335. address: this.orderInfo.address || ''
  336. }
  337. this.printDialogVisible = true
  338. },
  339. handleSelectionChange(val) {
  340. this.selectedItems = val
  341. },
  342. handleQtyChange(row) {
  343. // 可以在这里添加数量变化的处理逻辑
  344. console.log('数量已修改:', row.printQty)
  345. },
  346. handlePrintConfirm() {
  347. if (this.selectedItems.length === 0) {
  348. this.$message.warning('请至少选择一项商品')
  349. return
  350. }
  351. if (this.selectedItems.length > 7) {
  352. this.$message.warning('最多只能选择7项商品')
  353. return
  354. }
  355. if (!this.printForm.shipped_time) {
  356. this.$message.warning('请选择出库时间')
  357. return
  358. }
  359. if (!this.printForm.address) {
  360. this.$message.warning('请填写收货地址')
  361. return
  362. }
  363. this.printDialogVisible = false
  364. this.doPrint()
  365. },
  366. doPrint() {
  367. const printContent = document.getElementById('printContent')
  368. const printWindow = window.open('', '_blank')
  369. printWindow.document.write(`
  370. <html>
  371. <head>
  372. <title>签收单</title>
  373. <style>
  374. body {
  375. font-family: Arial, sans-serif;
  376. font-size: 12px;
  377. margin: 0;
  378. padding: 5mm;
  379. }
  380. table {
  381. width: 100%;
  382. border-collapse: collapse;
  383. font-size: 11px;
  384. }
  385. th, td {
  386. border: 1px solid #000;
  387. padding: 2px;
  388. text-align: center;
  389. }
  390. h2 {
  391. font-size: 16px;
  392. margin: 5px 0;
  393. }
  394. h3 {
  395. font-size: 14px;
  396. margin: 5px 0;
  397. }
  398. p {
  399. margin: 5px 0;
  400. font-size: 11px;
  401. }
  402. .signature-area { margin-top: 10px; }
  403. .logo-container { position: relative; }
  404. .logo { position: absolute; top: 0; right: 0; }
  405. #printContent {
  406. width: 230mm;
  407. height: 130mm;
  408. margin: 0 auto;
  409. }
  410. </style>
  411. </head>
  412. <body>
  413. ${printContent.innerHTML}
  414. </body>
  415. </html>
  416. `)
  417. printWindow.document.close()
  418. printWindow.focus()
  419. setTimeout(() => {
  420. printWindow.print()
  421. printWindow.close()
  422. }, 500)
  423. },
  424. handleUploadBefore(file) {
  425. let _this = this
  426. return new Promise((resolve, reject) => {
  427. let hz = file.name
  428. _this.fileName = hz
  429. let index = hz.lastIndexOf('.')
  430. hz = hz.substring(index + 1, hz.length)
  431. const isImg = hz === 'jpeg' || hz === 'png' || hz === 'jpg'
  432. const isLt5M = file.size / 1024 / 1024 < 3
  433. if (!isImg) {
  434. _this.$message.error('上传格式错误,仅支持 图片格式')
  435. reject()
  436. }
  437. if (!isLt5M) {
  438. _this.$message.error('不能大于3M')
  439. reject()
  440. }
  441. resolve()
  442. })
  443. },
  444. /** 上传成功后的钩子 更换图片 置空存储数组*/
  445. async uploadSuccess(response, file) {
  446. if (file.status === 'success') {
  447. this.addModel.shipped_url = response.url
  448. }
  449. },
  450. handleAdd() {
  451. if (!this.addModel.remark) {
  452. this.$message.error('必须填写备注')
  453. return
  454. }
  455. if (!this.addModel.shipped_time) {
  456. this.$message.error('请选择发货时间')
  457. return
  458. }
  459. this.addModel.shipped_time /= 1000
  460. const adminUser = JSON.parse(Storage.getItem('admin_user'))
  461. this.addModel.shipped_user = adminUser.realname
  462. this.addModel.order_no = this.orderNo
  463. API_Shipped.addModel(this.addModel).then(res => {
  464. this.$message.success('添加成功')
  465. this.dialogVisible = false
  466. this.addModel = {}
  467. this.GET_List()
  468. }).catch()
  469. },
  470. handlePictureCardPreview(url) {
  471. this.dialogImageUrl = url
  472. this.dialogImage = true
  473. }
  474. }
  475. }
  476. </script>
  477. <style type="text/scss" lang="scss" scoped>
  478. /deep/ .el-table td:not(.is-left) {
  479. text-align: center;
  480. }
  481. .inner-toolbar {
  482. display: flex;
  483. width: 100%;
  484. justify-content: space-between;
  485. }
  486. .toolbar-search {
  487. margin-right: 10px;
  488. }
  489. .goods-info {
  490. display: flex;
  491. align-items: center;
  492. .goods-image {
  493. img {
  494. width: 80px;
  495. height: 80px;
  496. }
  497. }
  498. .goods-name-box {
  499. text-align: left;
  500. .goods-name {
  501. display: -webkit-box;
  502. -webkit-box-orient: vertical;
  503. -webkit-line-clamp: 2;
  504. overflow: hidden;
  505. a:hover {
  506. color: #f42424 !important;
  507. }
  508. }
  509. }
  510. }
  511. </style>