edit.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  1. <template>
  2. <div class="storeTransferOutEdit-wrap">
  3. <a-page-header :ghost="false" :backIcon="false" class="storeTransferOutEdit-back" >
  4. <!-- 自定义的二级文字标题 -->
  5. <template slot="subTitle">
  6. <a id="storeTransferOutEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  7. <span style="margin: 0 15px;color: #666;">调往对象名称:{{ (basicInfoData&&basicInfoData.putPersonName) || '--' }}</span>
  8. </template>
  9. <!-- 操作区,位于 title 行的行尾 -->
  10. <template slot="extra">
  11. <a-button key="2" id="storeTransferOutEdit-preview-btn">打印预览</a-button>
  12. <a-button key="1" type="primary" id="storeTransferOutEdit-print-btn">快速打印</a-button>
  13. </template>
  14. </a-page-header>
  15. <!-- 选择产品 -->
  16. <a-card size="small" :bordered="false" class="storeTransferOutEdit-cont">
  17. <a-collapse :activeKey="['1']">
  18. <a-collapse-panel key="1" header="选择产品">
  19. <!-- 筛选条件 -->
  20. <div class="table-page-search-wrapper">
  21. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  22. <a-row :gutter="15">
  23. <a-col :md="6" :sm="24">
  24. <a-form-item label="产品编码" prop="productCode">
  25. <a-input id="storeTransferOutEdit-productCode" v-model="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  26. </a-form-item>
  27. </a-col>
  28. <a-col :md="6" :sm="24">
  29. <a-form-item label="产品名称" prop="productName">
  30. <a-input id="storeTransferOutEdit-productName" v-model="queryParam.productName" placeholder="请输入产品名称" allowClear />
  31. </a-form-item>
  32. </a-col>
  33. <a-col :md="6" :sm="24">
  34. <a-form-item label="仓库">
  35. <a-select id="storeTransferOutEdit-warehouseSn" placeholder="请选择仓库" v-model="queryParam.warehouseSn" >
  36. <a-select-option v-for="item in warehouseList" :key="item.warehouseSn" :value="item.warehouseSn">{{ item.name }}</a-select-option>
  37. </a-select>
  38. </a-form-item>
  39. </a-col>
  40. <template v-if="advanced">
  41. <a-col :md="6" :sm="24">
  42. <a-form-item label="产品分类">
  43. <a-cascader
  44. @change="changeProductType"
  45. change-on-select
  46. v-model="productType"
  47. expand-trigger="hover"
  48. :options="productTypeList"
  49. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  50. id="storeTransferOutEdit-productType"
  51. placeholder="请选择产品分类"
  52. allowClear />
  53. </a-form-item>
  54. </a-col>
  55. <a-col :md="6" :sm="24">
  56. <a-form-item label="产品品牌">
  57. <a-select
  58. placeholder="请选择产品品牌"
  59. id="storeTransferOutEdit-brandSn"
  60. allowClear
  61. v-model="queryParam.brandSn"
  62. :showSearch="true"
  63. option-filter-prop="children"
  64. :filter-option="filterOption">
  65. <a-select-option v-for="item in productBrandList" :key="item.brandSn" :value="item.brandSn">{{ item.brandName }}</a-select-option>
  66. </a-select>
  67. </a-form-item>
  68. </a-col>
  69. </template>
  70. <a-col :md="6" :sm="24" style="margin-bottom: 24px;">
  71. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="storeTransferOutList-refresh">查询</a-button>
  72. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="storeTransferOutList-reset">重置</a-button>
  73. <a @click="advanced=!advanced" style="margin-left: 8px">
  74. {{ advanced ? '收起' : '展开' }}
  75. <a-icon :type="advanced ? 'up' : 'down'"/>
  76. </a>
  77. </a-col>
  78. </a-row>
  79. </a-form>
  80. </div>
  81. <!-- 列表 -->
  82. <s-table
  83. class="sTable"
  84. ref="table"
  85. size="small"
  86. :rowKey="(record) => record.stockSn+record.productSn+record.warehouseSn+record.warehouseLocationSn"
  87. :columns="columns"
  88. :customRow="handleClickRow"
  89. :data="loadData"
  90. :scroll="{ x: 1180, y: 300 }"
  91. :defaultLoadData="false"
  92. bordered>
  93. <!-- 操作 -->
  94. <template slot="action" slot-scope="text, record">
  95. <a-button size="small" type="primary" class="button-primary" @click="handleAdd(record)" id="storeTransferOutEdit-add-btn">添加</a-button>
  96. </template>
  97. </s-table>
  98. </a-collapse-panel>
  99. </a-collapse>
  100. </a-card>
  101. <!-- 已选产品 -->
  102. <a-card size="small" :bordered="false" class="storeTransferOutEdit-cont">
  103. <a-collapse :activeKey="['1']">
  104. <a-collapse-panel key="1" header="已选产品">
  105. <!-- 总计 -->
  106. <a-alert type="info" showIcon style="margin-bottom:15px">
  107. <div slot="message">总款数 <strong>{{ (productTotal&&productTotal.productTotalCategory) || 0 }}</strong> ,总数量 <strong>{{ (productTotal&&productTotal.productTotalQty) || 0 }}</strong> ,总成本¥<strong>{{ (productTotal&&productTotal.productTotalCost) || 0 }}</strong></div>
  108. </a-alert>
  109. <!-- 筛选条件 -->
  110. <a-row :gutter="15">
  111. <a-col :span="20">
  112. <div class="table-page-search-wrapper">
  113. <a-form layout="inline" @keyup.enter.native="getChooseProductList(1)">
  114. <a-row :gutter="15">
  115. <a-col :md="6" :sm="24">
  116. <a-form-item label="产品编码" prop="productCode">
  117. <a-input id="storeTransferOutEdit-productCode" v-model="chooseQueryParam.productCode" placeholder="请输入产品编码" allowClear />
  118. </a-form-item>
  119. </a-col>
  120. <a-col :md="6" :sm="24">
  121. <a-form-item label="产品名称" prop="productName">
  122. <a-input id="storeTransferOutEdit-productName" v-model="chooseQueryParam.productName" placeholder="请输入产品名称" allowClear />
  123. </a-form-item>
  124. </a-col>
  125. <a-col :md="6" :sm="24" style="margin-bottom: 24px;">
  126. <a-button type="primary" @click="getChooseProductList(1)" :disabled="chooseDisabled" id="storeTransferOutList-refresh">查询</a-button>
  127. <a-button style="margin-left: 8px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="storeTransferOutList-reset">重置</a-button>
  128. </a-col>
  129. </a-row>
  130. </a-form>
  131. </div>
  132. </a-col>
  133. <a-col :span="4" style="text-align: right;">
  134. <a-button size="small" id="storeTransferOutEdit-import-btn">导入明细</a-button>
  135. </a-col>
  136. </a-row>
  137. <!-- 列表 -->
  138. <a-table
  139. class="sTable"
  140. ref="chooseTable"
  141. size="small"
  142. :rowKey="(record) => record.id"
  143. :columns="chooseColumns"
  144. :dataSource="chooseLoadData"
  145. :scroll="{ x: 1335, y: 300 }"
  146. :pagination="choosePaginationProps"
  147. bordered>
  148. <!-- 调出数量 -->
  149. <template slot="outQty" slot-scope="text, record">
  150. <a-input-number
  151. id="storeTransferOutEdit-outQty"
  152. v-model="record.outQty"
  153. :precision="0"
  154. :min="1"
  155. :max="999999"
  156. placeholder="请输入"
  157. @blur="e => outQtyBlur(e.target.value, record)"
  158. style="width: 100%;" />
  159. </template>
  160. <!-- 操作 -->
  161. <template slot="action" slot-scope="text, record">
  162. <a-button size="small" type="primary" class="button-error" @click="handleDel(record)" id="storeTransferOutEdit-del-btn">删除</a-button>
  163. </template>
  164. </a-table>
  165. </a-collapse-panel>
  166. </a-collapse>
  167. </a-card>
  168. <a-affix :offset-bottom="0">
  169. <div style="text-align: center;width: 100%;background-color: #fff;padding: 12px 0;box-shadow: 0 0 20px #dcdee2;">
  170. <a-button
  171. type="primary"
  172. id="storeTransferOutEdit-submit"
  173. size="large"
  174. class="button-primary"
  175. @click="handleSubmit"
  176. style="padding: 0 60px;">提交</a-button>
  177. </div>
  178. </a-affix>
  179. </div>
  180. </template>
  181. <script>
  182. import { STable, VSelect } from '@/components'
  183. import { getOperationalPrecision } from '@/libs/tools.js'
  184. import { storeCallOutDetailList, storeCallOutDetail, storeCallOutDetailCount, storeCallOutDetailSave, storeCallOutDetailDel, storeCallOutSubmit } from '@/api/storeCallOut'
  185. import { dealerProductBrandQuery } from '@/api/dealerProductBrand'
  186. import { dealerProductTypeList } from '@/api/dealerProductType'
  187. import { warehouseAllList } from '@/api/warehouse'
  188. import { productQuery } from '@/api/allocWarehouse'
  189. export default {
  190. components: { STable, VSelect },
  191. data () {
  192. return {
  193. queryParam: {
  194. productCode: '',
  195. productName: '',
  196. warehouseSn: undefined,
  197. brandSn: undefined,
  198. productTypeSn1: undefined,
  199. productTypeSn2: undefined,
  200. productTypeSn3: undefined
  201. },
  202. chooseQueryParam: {
  203. productCode: '',
  204. productName: ''
  205. },
  206. disabled: false, // 查询、重置按钮是否可操作
  207. chooseDisabled: false, // 查询、重置按钮是否可操作
  208. advanced: false, // 高级搜索 展开/关闭
  209. productBrandList: [], // 产品品牌 下拉数据
  210. productTypeList: [], // 产品分类 下拉数据
  211. productType: [],
  212. warehouseList: [], // 仓库 下拉数据
  213. // 表头
  214. columns: [
  215. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  216. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center' },
  217. { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true },
  218. { title: '单位', dataIndex: 'unit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  219. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  220. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  221. { title: '库存数量', dataIndex: 'currentQty', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  222. { title: '成本价(¥)', dataIndex: 'putCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  223. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  224. ],
  225. // 加载数据方法 必须为 Promise 对象
  226. loadData: parameter => {
  227. this.disabled = true
  228. return productQuery(Object.assign(parameter, this.queryParam)).then(res => {
  229. const data = res.data
  230. const no = (data.pageNo - 1) * data.pageSize
  231. for (var i = 0; i < data.list.length; i++) {
  232. data.list[i].no = no + i + 1
  233. }
  234. this.disabled = false
  235. return data
  236. })
  237. },
  238. // 表头
  239. chooseColumns: [
  240. { title: '序号', dataIndex: 'no', width: 80, align: 'center' },
  241. { title: '产品编码', dataIndex: 'productCode', width: 220, align: 'center', customRender: function (text) { return text || '--' } },
  242. { title: '产品名称', dataIndex: 'productName', align: 'center', ellipsis: true },
  243. { title: '单位', dataIndex: 'productUnit', width: 100, align: 'center', customRender: function (text) { return text || '--' } },
  244. { title: '成本价(¥)', dataIndex: 'outCost', width: 100, align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  245. { title: '仓库', dataIndex: 'warehouseName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  246. { title: '仓位', dataIndex: 'warehouseLocationName', width: 140, align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  247. { title: '调出数量', scopedSlots: { customRender: 'outQty' }, width: 140, align: 'center' },
  248. { title: '成本小计(¥)', dataIndex: 'costSubtotal', width: 115, align: 'center' },
  249. { title: '操作', scopedSlots: { customRender: 'action' }, width: 100, align: 'center', fixed: 'right' }
  250. ],
  251. chooseLoadData: [],
  252. choosePageNo: 1, // 分页页码
  253. choosePageSize: 10, // 分页 每页多少条
  254. choosePaginationProps: {
  255. showSizeChanger: true, // 是否可以改变 pageSize
  256. total: 0, // 分页总条数
  257. current: 1,
  258. onShowSizeChange: (current, pageSize) => this.changeChoosePageSize(current, pageSize),
  259. onChange: (current) => this.changeChoosePage(current)
  260. },
  261. basicInfoData: null, // 基本信息
  262. productTotal: null // 合计
  263. }
  264. },
  265. methods: {
  266. // 重置
  267. resetSearchForm () {
  268. this.queryParam.productCode = ''
  269. this.queryParam.productName = ''
  270. this.queryParam.warehouseSn = undefined
  271. this.queryParam.brandSn = undefined
  272. this.queryParam.productTypeSn1 = undefined
  273. this.queryParam.productTypeSn2 = undefined
  274. this.queryParam.productTypeSn3 = undefined
  275. this.$refs.table.refresh(true)
  276. },
  277. // 双击快速添加
  278. handleClickRow (record) {
  279. return {
  280. on: {
  281. dblclick: (event) => {
  282. this.handleAdd(record)
  283. }
  284. }
  285. }
  286. },
  287. // 已选产品 重置
  288. chooseResetSearchForm () {
  289. this.chooseQueryParam.productCode = ''
  290. this.chooseQueryParam.productName = ''
  291. this.getChooseProductList(1)
  292. },
  293. // 基本信息
  294. getDetail () {
  295. storeCallOutDetail({ id: this.$route.params.id }).then(res => {
  296. if (res.status == 200) {
  297. this.basicInfoData = res.data
  298. } else {
  299. this.basicInfoData = null
  300. }
  301. })
  302. },
  303. // 添加/编辑
  304. handleAdd (row, isEdit) {
  305. const params = {
  306. id: isEdit ? row.id : undefined,
  307. storeCallOutSn: this.$route.params.sn,
  308. outCost: isEdit ? row.outCost : row.putCost,
  309. outQty: isEdit ? row.outQty : 1, // 添加时调出数量默认为1
  310. productSn: row.productSn,
  311. productCode: row.productCode,
  312. productOrigCode: row.productOrigCode || undefined,
  313. productTypeSn1: row.productTypeSn1,
  314. productTypeSn2: row.productTypeSn2,
  315. productTypeSn3: row.productTypeSn3,
  316. brandSn: row.brandSn,
  317. warehouseSn: row.warehouseSn,
  318. warehouseLocationSn: row.warehouseLocationSn
  319. }
  320. if (isEdit) { // 编辑
  321. // 清空数量时,值应保持未清空前的值,因数量不可为空
  322. if (!row.outQty || row.outQty == row.outQtyBackups) {
  323. row.outQty = row.outQtyBackups
  324. return
  325. }
  326. }
  327. storeCallOutDetailSave(params).then(res => {
  328. if (res.status == 200) {
  329. this.$message.success(res.message)
  330. this.$refs.table.refresh()
  331. this.getChooseProductList()
  332. }
  333. })
  334. },
  335. // 删除
  336. handleDel (row) {
  337. const _this = this
  338. this.$confirm({
  339. title: '提示',
  340. content: '删除后不可恢复,确定要进行删除吗?',
  341. centered: true,
  342. onOk () {
  343. storeCallOutDetailDel({ id: row.id }).then(res => {
  344. if (res.status == 200) {
  345. _this.$message.success(res.message)
  346. _this.$refs.table.refresh()
  347. _this.getChooseProductList()
  348. }
  349. })
  350. }
  351. })
  352. },
  353. // 提交
  354. handleSubmit () {
  355. const _this = this
  356. storeCallOutSubmit({ id: this.$route.params.id }).then(res => {
  357. if (res.status == 200) {
  358. this.$message.success(res.message)
  359. setTimeout(() => {
  360. _this.handleBack()
  361. }, 1000)
  362. }
  363. })
  364. },
  365. // 合计
  366. getDetailCount (params) {
  367. storeCallOutDetailCount(params).then(res => {
  368. if (res.status == 200) {
  369. this.productTotal = res.data
  370. } else {
  371. this.productTotal = null
  372. }
  373. })
  374. },
  375. // 导入明细
  376. handleImport () {
  377. console.log(333)
  378. },
  379. // 返回列表
  380. handleBack () {
  381. this.$router.push({ path: '/allocationManagement/storeTransferOut/list' })
  382. },
  383. // 已选产品 分页 一页多少条change
  384. changeChoosePageSize (current, pageSize) {
  385. this.choosePageNo = current
  386. this.choosePageSize = pageSize
  387. this.getChooseProductList()
  388. },
  389. // 已选产品 分页 页码change
  390. changeChoosePage (current) {
  391. this.choosePageNo = current
  392. this.getChooseProductList()
  393. },
  394. // 已选产品列表数据
  395. getChooseProductList (pageNo) {
  396. this.choosePageNo = this.choosePageNo || pageNo
  397. this.chooseDisabled = true
  398. const params = {
  399. pageNo: this.choosePageNo,
  400. pageSize: this.choosePageSize,
  401. storeCallOutSn: this.$route.params.sn
  402. }
  403. storeCallOutDetailList(Object.assign(params, this.chooseQueryParam)).then(res => {
  404. if (res.status == 200) {
  405. // 合计
  406. this.getDetailCount(Object.assign(params, this.chooseQueryParam))
  407. const data = res.data
  408. this.choosePaginationProps.total = Number(res.data.count) || 0
  409. this.choosePaginationProps.current = data.pageNo
  410. const no = (data.pageNo - 1) * data.pageSize
  411. for (var i = 0; i < data.list.length; i++) {
  412. data.list[i].no = no + i + 1
  413. data.list[i].outQtyBackups = data.list[i].outQty
  414. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  415. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].outCost, data.list[i].outQty)
  416. }
  417. this.chooseLoadData = data.list
  418. this.chooseDisabled = false
  419. } else {
  420. this.choosePaginationProps.total = 0
  421. this.choosePaginationProps.current = 1
  422. this.chooseLoadData = []
  423. }
  424. })
  425. },
  426. // 已选产品 调出数量 blur
  427. outQtyBlur (val, record) {
  428. // 光标移出,值发生改变再调用编辑接口
  429. if (val != record.outQtyBackups) {
  430. this.handleAdd(record, 'edit')
  431. }
  432. },
  433. // 产品分类 change
  434. changeProductType (val, opt) {
  435. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  436. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  437. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  438. },
  439. // 产品品牌 列表
  440. getProductBrand () {
  441. // sysFlag不传,此处应查询所有产品
  442. dealerProductBrandQuery({}).then(res => {
  443. if (res.status == 200) {
  444. this.productBrandList = res.data
  445. } else {
  446. this.productBrandList = []
  447. }
  448. })
  449. },
  450. // 产品分类 列表
  451. getProductType () {
  452. dealerProductTypeList({}).then(res => {
  453. if (res.status == 200) {
  454. this.productTypeList = res.data
  455. } else {
  456. this.productTypeList = []
  457. }
  458. })
  459. },
  460. // 仓库下拉数据
  461. getWarehouseList (type) {
  462. warehouseAllList({}).then(res => {
  463. if (res.status == 200) {
  464. this.warehouseList = res.data
  465. } else {
  466. this.warehouseList = []
  467. }
  468. })
  469. },
  470. filterOption (input, option) {
  471. return (
  472. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  473. )
  474. }
  475. },
  476. beforeRouteEnter (to, from, next) {
  477. next(vm => {
  478. vm.getDetail()
  479. vm.getChooseProductList(1)
  480. vm.getWarehouseList()
  481. vm.getProductBrand()
  482. vm.getProductType()
  483. })
  484. }
  485. }
  486. </script>
  487. <style lang="less">
  488. .storeTransferOutEdit-wrap{
  489. .storeTransferOutEdit-back{
  490. margin-bottom: 15px;
  491. }
  492. .storeTransferOutEdit-cont{
  493. margin-bottom: 15px;
  494. .sub-title{
  495. font-size: 12px;
  496. color: #808695;
  497. margin-left: 10px;
  498. }
  499. .tag-txt{
  500. font-size: 12px;
  501. color: #ed1c24;
  502. }
  503. .edit-circle-btn{
  504. margin-left: 15px;
  505. i{
  506. vertical-align: text-bottom;
  507. }
  508. }
  509. .import-btn{
  510. margin-left: 15px;
  511. }
  512. }
  513. }
  514. </style>