edit.vue 22 KB

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