edit.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <template>
  2. <div class="purchaseOrderEdit-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="purchaseOrderEdit-cont">
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="purchaseOrderEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. <p class="billno">单号:{{ detail&&detail.purchaseBillNo }}</p>
  8. </template>
  9. <!-- 操作区,位于 title 行的行尾 -->
  10. <template slot="extra">
  11. <a-button key="2" id="purchaseOrderEdit-preview-btn">打印预览</a-button>
  12. <a-button key="1" type="primary" id="purchaseOrderEdit-print-btn">快速打印</a-button>
  13. </template>
  14. </a-page-header>
  15. <!-- 基础信息 -->
  16. <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
  17. <a-collapse :activeKey="['1']">
  18. <a-collapse-panel key="1">
  19. <template slot="header">
  20. 基础信息
  21. <a-button
  22. type="primary"
  23. shape="circle"
  24. size="small"
  25. icon="edit"
  26. class="edit-circle-btn"
  27. id="purchaseOrderEdit-edit-circle-btn"
  28. @click.stop="handleEditInfo" />
  29. </template>
  30. <a-descriptions :column="2">
  31. <a-descriptions-item label="供应商">{{ detail&&detail.dealerName }}</a-descriptions-item>
  32. <a-descriptions-item label="支付方式">{{ detail&&detail.settleStyleEntity.name }}</a-descriptions-item>
  33. <a-descriptions-item label="收货人">{{ detail&&detail.consigneeName }}({{ detail&&detail.consigneeTel }})</a-descriptions-item>
  34. <a-descriptions-item label="收货地址">
  35. {{ detail&&detail.shippingAddressProvinceName }} -
  36. {{ detail&&detail.shippingAddressCityName }} -
  37. {{ detail&&detail.shippingAddressCountyName }} -
  38. {{ detail&&detail.shippingAddress }}
  39. </a-descriptions-item>
  40. </a-descriptions>
  41. </a-collapse-panel>
  42. </a-collapse>
  43. </a-card>
  44. <!-- 选择产品 -->
  45. <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
  46. <a-collapse :activeKey="['1']">
  47. <a-collapse-panel key="1">
  48. <template slot="header">
  49. 选择产品<span class="sub-title">①输入查询条件--->②查找到需要采购的产品--->③录入采购数量--->④点击“添加”</span>
  50. <p class="tag-txt">注意:仅限采购【箭冠】产品。自建产品的采购入库请使用“散件入库”功能</p>
  51. </template>
  52. <!-- 选择产品 -->
  53. <div>
  54. <!-- 搜索条件 -->
  55. <div class="table-page-search-wrapper">
  56. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  57. <a-row :gutter="15">
  58. <a-col :md="6" :sm="24">
  59. <a-form-item label="关键词">
  60. <a-input id="purchaseOrderEdit-bundleName" v-model.trim="queryParam.queryWord" allowClear placeholder="产品名称/产品编码/原厂编码/适用车型"/>
  61. </a-form-item>
  62. </a-col>
  63. <a-col :md="6" :sm="24">
  64. <a-form-item label="产品品牌">
  65. <ProductBrand id="purchaseOrderEdit-productBrand" v-model="queryParam.productBrandSn"></ProductBrand>
  66. </a-form-item>
  67. </a-col>
  68. <a-col :md="6" :sm="24">
  69. <a-form-item label="产品类别">
  70. <ProductType id="purchaseOrderEdit-productType" @change="changeProductType" v-model="productType"></ProductType>
  71. </a-form-item>
  72. </a-col>
  73. <template v-if="advanced">
  74. <a-col :md="6" :sm="24">
  75. <a-form-item label="适用车型">
  76. <a-cascader
  77. :options="typeData"
  78. expand-trigger="hover"
  79. id="purchaseOrderEdit-state"
  80. placeholder="请选择适用车型"
  81. allowClear
  82. v-model="queryParam.brand" />
  83. </a-form-item>
  84. </a-col>
  85. </template>
  86. <a-col :md="6" :sm="24">
  87. <a-button style="margin-bottom: 18px;" type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="purchaseOrderEdit-refresh">查询</a-button>
  88. <a-button style="margin: 0 0 18px 8px" @click="resetSearchForm" :disabled="disabled" id="purchaseOrderEdit-reset">重置</a-button>
  89. <a @click="advanced=!advanced" style="margin-left: 8px">
  90. {{ advanced ? '收起' : '展开' }}
  91. <a-icon :type="advanced ? 'up' : 'down'"/>
  92. </a>
  93. </a-col>
  94. </a-row>
  95. </a-form>
  96. </div>
  97. <!-- 列表 -->
  98. <s-table
  99. class="sTable"
  100. ref="table"
  101. size="default"
  102. :rowKey="(record) => record.id"
  103. :columns="columns"
  104. :data="loadData"
  105. :scroll="{ x: 1370, y:300 }"
  106. :defaultLoadData="false"
  107. bordered>
  108. <!-- 采购数量 -->
  109. <template slot="storageQuantity" slot-scope="text, record">
  110. <a-input-number
  111. v-model="record.qty"
  112. :precision="0"
  113. :min="0"
  114. :max="999999"
  115. placeholder="请输入数量" />
  116. </template>
  117. <!-- 操作 -->
  118. <template slot="action" slot-scope="text, record">
  119. <a-button
  120. size="small"
  121. type="primary"
  122. class="button-info"
  123. :loading="addLoading"
  124. @click="handleAdd(record,0)"
  125. :disabled="record.purchasePrice<=0"
  126. id="purchaseOrderEdit-add-btn">添加</a-button>
  127. </template>
  128. </s-table>
  129. </div>
  130. </a-collapse-panel>
  131. </a-collapse>
  132. </a-card>
  133. <!-- 已选产品 -->
  134. <a-card size="small" :bordered="false" class="purchaseOrderEdit-cont">
  135. <a-collapse :activeKey="['1']">
  136. <a-collapse-panel key="1">
  137. <template slot="header">
  138. 已选产品
  139. <a-button size="small" class="import-btn" id="purchaseOrderEdit-import-btn" @click.stop="handleImport">导入明细</a-button>
  140. </template>
  141. <!-- 已选产品 -->
  142. <div>
  143. <!-- 总计 -->
  144. <a-alert type="info" showIcon style="margin-bottom:15px">
  145. <div slot="message">产品款数 <strong>{{ detail&&detail.totalCategory }}</strong> ,
  146. 采购数量合计 <strong>{{ detail&&detail.totalQty }}</strong> ,
  147. 采购金额合计¥<strong>{{ detail&&detail.totalAmount }}</strong></div>
  148. </a-alert>
  149. <!-- 列表 -->
  150. <s-table
  151. class="sTable"
  152. ref="purchaseTable"
  153. size="default"
  154. :rowKey="(record) => record.id"
  155. :columns="chooseColumns"
  156. :data="chooseLoadData"
  157. :scroll="{ x: 970, y: 300 }"
  158. bordered>
  159. <!-- 采购数量 -->
  160. <template slot="storageQuantity" slot-scope="text, record">
  161. <a-input-number
  162. id="purchaseOrderEdit-qty"
  163. v-model="record.qty"
  164. :precision="0"
  165. :min="1"
  166. :max="999999"
  167. @blur="e => qtyBlur(e.target.value, record)"
  168. placeholder="请输入" />
  169. </template>
  170. <!-- 操作 -->
  171. <template slot="action" slot-scope="text, record">
  172. <a-button
  173. size="small"
  174. type="primary"
  175. class="button-error"
  176. :loading="delLoading"
  177. @click="handleDel(record)"
  178. id="purchaseOrderEdit-del-btn">删除</a-button>
  179. </template>
  180. </s-table>
  181. </div>
  182. </a-collapse-panel>
  183. </a-collapse>
  184. </a-card>
  185. <a-affix :offset-bottom="0" v-if="detail">
  186. <div style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
  187. <a-button
  188. type="primary"
  189. id="purchaseOrderEdit-submit-btn"
  190. size="large"
  191. class="button-primary"
  192. :loading="subLoading"
  193. @click="handleSubmit"
  194. style="padding: 0 60px;">提交</a-button>
  195. </div>
  196. </a-affix>
  197. <!-- 选择基本信息弹框 -->
  198. <basic-info-modal ref="baseInfo" :openModal="openModal" @ok="handleOk" @cancel="openModal=false" />
  199. </div>
  200. </template>
  201. <script>
  202. import { STable, VSelect } from '@/components'
  203. import basicInfoModal from './basicInfoModal.vue'
  204. import ProductType from '../../common/productType.js'
  205. import ProductBrand from '../../common/productBrand.js'
  206. import { purchaseDetailBySn, purchaseWriteSubmit } from '@/api/purchase'
  207. import { purchaseDetailList, purchaseDetailSave, purchaseDetailDel, purchaseDetailCount } from '@/api/purchaseDetail'
  208. import { productListPurchase } from '@/api/product'
  209. export default {
  210. components: { STable, VSelect, basicInfoModal, ProductType, ProductBrand },
  211. data () {
  212. return {
  213. openModal: false, // 选择基本信息弹框是否显示
  214. detail: null, // 详细信息
  215. subLoading: false,
  216. // 选择产品
  217. addLoading: false,
  218. productType: [],
  219. queryParam: {
  220. productBrandSn: undefined,
  221. queryWord: '',
  222. brand: '',
  223. productTypeSn1: '', // 产品一级分类
  224. productTypeSn2: '', // 产品二级分类
  225. productTypeSn3: '' // 产品三级分类
  226. },
  227. brandData: [], // 产品品牌 下拉数据
  228. typeData: [], // 产品类别 下拉数据
  229. advanced: false, // 高级搜索 展开/关闭
  230. disabled: false, // 查询、重置按钮是否可操作
  231. // 表头
  232. columns: [
  233. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  234. { title: '产品编码', dataIndex: 'code', width: 200, align: 'center', sorter: true },
  235. { title: '产品名称', dataIndex: 'name', align: 'center', customRender: function (text) { return text || '--' } },
  236. { title: '原厂编码', dataIndex: 'origCode', width: 200, align: 'center', customRender: function (text) { return text == ' ' ? '--' : text } },
  237. { title: '箱/单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  238. { title: '采购单价', dataIndex: 'purchasePrice', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) }, fixed: 'right' },
  239. { title: '采购数量', dataIndex: 'qty', scopedSlots: { customRender: 'storageQuantity' }, width: 150, align: 'center', fixed: 'right' },
  240. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  241. ],
  242. // 加载数据方法 必须为 Promise 对象
  243. loadData: parameter => {
  244. this.disabled = true
  245. return productListPurchase(Object.assign(parameter, this.queryParam)).then(res => {
  246. const data = res.data
  247. const no = (data.pageNo - 1) * data.pageSize
  248. for (var i = 0; i < data.list.length; i++) {
  249. data.list[i].no = no + i + 1
  250. data.list[i].qty = 1
  251. }
  252. this.disabled = false
  253. return data
  254. })
  255. },
  256. // -------已选产品-------------
  257. orderCountData: null,
  258. delLoading: false,
  259. // 表头
  260. chooseColumns: [
  261. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  262. { title: '产品编码', dataIndex: 'dealerProductEntity.code', width: 140, align: 'center', sorter: true },
  263. { title: '产品名称', dataIndex: 'dealerProductEntity.name', align: 'center', customRender: function (text) { return text || '--' } },
  264. { title: '采购单价', dataIndex: 'price', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  265. { title: '采购数量', scopedSlots: { customRender: 'storageQuantity' }, width: 150, align: 'center' },
  266. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  267. { title: '采购金额', dataIndex: 'totalAmount', width: 100, align: 'center', customRender: function (text) { return '¥' + (text || 0) } },
  268. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  269. ],
  270. // 加载数据方法 必须为 Promise 对象
  271. chooseLoadData: parameter => {
  272. this.disabled = true
  273. // 查询总计
  274. const params = Object.assign(parameter, { purchaseBillSn: this.$route.params.sn })
  275. // this.getCountQuery(params)
  276. return purchaseDetailList(params).then(res => {
  277. const data = res.data
  278. const no = (data.pageNo - 1) * data.pageSize
  279. for (var i = 0; i < data.list.length; i++) {
  280. data.list[i].no = no + i + 1
  281. }
  282. this.disabled = false
  283. return data
  284. })
  285. }
  286. }
  287. },
  288. methods: {
  289. // 获取采购单明细统计
  290. getCountQuery (params) {
  291. purchaseDetailCount(params).then(res => {
  292. this.orderCountData = res.data || null
  293. })
  294. },
  295. // 获取采购单基本信息
  296. getOrderDetail () {
  297. purchaseDetailBySn({ sn: this.$route.params.sn }).then(res => {
  298. if (res.status == 200) {
  299. this.detail = res.data
  300. }
  301. })
  302. },
  303. // 基本信息编辑成功
  304. handleOk (data) {
  305. this.openModal = false
  306. this.getOrderDetail()
  307. },
  308. // 编辑基本信息
  309. handleEditInfo () {
  310. this.openModal = true
  311. this.$refs.baseInfo.setData(this.detail)
  312. },
  313. // ---已选产品-----
  314. // 删除产品
  315. handleDel (row) {
  316. const _this = this
  317. this.$confirm({
  318. title: '提示',
  319. content: '确认要删除吗?',
  320. centered: true,
  321. closable: true,
  322. onOk () {
  323. _this.delLoading = true
  324. purchaseDetailDel({ id: row.id }).then(res => {
  325. if (res.status == 200) {
  326. _this.resetPurchaseDetail(true)
  327. _this.$message.success(res.message)
  328. }
  329. _this.delLoading = false
  330. })
  331. }
  332. })
  333. },
  334. // 重新查询已选产品
  335. resetPurchaseDetail (flag) {
  336. this.$refs.purchaseTable.refresh(!!flag)
  337. this.getOrderDetail()
  338. },
  339. // 修改数量后
  340. qtyBlur (val, record) {
  341. console.log(val, record)
  342. this.handleAdd(record, 1)
  343. },
  344. // 导入明细
  345. handleImport () {
  346. console.log(333)
  347. },
  348. // ---------产品库--------
  349. filterOption (input, option) {
  350. return (
  351. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  352. )
  353. },
  354. // 产品分类 change
  355. changeProductType (val, opt) {
  356. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  357. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  358. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  359. },
  360. // 重置产品库
  361. resetSearchForm () {
  362. this.queryParam = {
  363. productBrandSn: undefined,
  364. productTypeSn1: '', // 产品一级分类
  365. productTypeSn2: '', // 产品二级分类
  366. productTypeSn3: '', // 产品三级分类
  367. queryWord: '',
  368. brand: ''
  369. }
  370. this.productType = []
  371. this.$refs.table.refresh(true)
  372. },
  373. // 添加或修改
  374. handleAdd (row, type) {
  375. let params = {}
  376. // 添加
  377. if (type == 0) {
  378. params.productSn = row.productSn
  379. params.purchaseBillSn = this.detail.purchaseBillSn
  380. params.purchaseBillNo = this.detail.purchaseBillNo
  381. params.price = row.purchasePrice
  382. params.qty = row.qty
  383. } else {
  384. params = row
  385. }
  386. this.addLoading = true
  387. purchaseDetailSave(params).then(res => {
  388. if (res.status == 200) {
  389. this.resetPurchaseDetail()
  390. this.$message.success(res.message)
  391. }
  392. this.addLoading = false
  393. })
  394. },
  395. // ------------产品库 end --------
  396. // 提交
  397. handleSubmit () {
  398. const _this = this
  399. this.subLoading = true
  400. purchaseWriteSubmit({ id: this.detail.id }).then(res => {
  401. if (res.status == 200) {
  402. this.$message.success(res.message)
  403. setTimeout(() => {
  404. _this.handleBack()
  405. }, 1000)
  406. }
  407. _this.subLoading = false
  408. })
  409. },
  410. // 返回列表
  411. handleBack () {
  412. this.$router.push({ name: 'purchaseOrderList' })
  413. }
  414. },
  415. beforeRouteEnter (to, from, next) {
  416. next(vm => {
  417. vm.openModal = false
  418. vm.getOrderDetail()
  419. })
  420. }
  421. }
  422. </script>
  423. <style lang="less">
  424. .purchaseOrderEdit-wrap{
  425. .billno{
  426. margin: 0 0 0 30px;
  427. font-size: 18px;
  428. font-weight: 600;
  429. display: inline-block;
  430. vertical-align: top;
  431. color: #666;
  432. }
  433. .purchaseOrderEdit-cont{
  434. margin-bottom: 15px;
  435. .sub-title{
  436. font-size: 12px;
  437. color: #808695;
  438. margin-left: 10px;
  439. }
  440. .tag-txt{
  441. font-size: 12px;
  442. color: #ed1c24;
  443. }
  444. .edit-circle-btn{
  445. margin-left: 15px;
  446. i{
  447. vertical-align: text-bottom;
  448. }
  449. }
  450. .import-btn{
  451. margin-left: 15px;
  452. }
  453. }
  454. }
  455. </style>