edit.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. <template>
  2. <div class="chainTransferInEdit-wrap">
  3. <a-spin :spinning="spinning" tip="Loading...">
  4. <a-page-header :ghost="false" :backIcon="false" class="chainTransferInEdit-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="chainTransferInEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. <!-- 操作区,位于 title 行的行尾 -->
  10. <template slot="extra" v-if="$hasPermissions('B_allocLinkagePutPrint')">
  11. <Print :disabled="localDataSource.length==0" :showExport="false" @handlePrint="handlePrint"></Print>
  12. </template>
  13. </a-page-header>
  14. <!-- 基础信息 -->
  15. <a-card size="small" :bordered="false" class="chainTransferInEdit-cont">
  16. <a-collapse :activeKey="['1']">
  17. <a-collapse-panel key="1" header="基础信息">
  18. <a-descriptions :column="3">
  19. <a-descriptions-item label="调入单号">{{ (basicInfoData&&basicInfoData.allocationLinkagePutNo) || '--' }}</a-descriptions-item>
  20. <a-descriptions-item label="调出对象">{{ (basicInfoData&&basicInfoData.outTenantName) || '--' }}</a-descriptions-item>
  21. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  22. <a-descriptions-item label="财务状态">{{ (basicInfoData&&basicInfoData.settleStateDictValue) || '--' }}</a-descriptions-item>
  23. </a-descriptions>
  24. </a-collapse-panel>
  25. </a-collapse>
  26. </a-card>
  27. <a-card size="small" :bordered="false" class="chainTransferInEdit-cont">
  28. <!-- 总计 -->
  29. <a-alert type="info" style="margin-bottom: 10px">
  30. <div slot="message">
  31. 总款数 <strong>{{ (basicInfoData&&(basicInfoData.productTotalCategory || basicInfoData.productTotalCategory==0)) ? basicInfoData.productTotalCategory : '--' }}</strong> ,
  32. 总数量 <strong>{{ (basicInfoData&&(basicInfoData.productTotalQty || basicInfoData.productTotalQty==0)) ? basicInfoData.productTotalQty : '--' }}</strong> ,
  33. 总成本 <strong>{{ (basicInfoData&&(basicInfoData.productTotalCost || basicInfoData.productTotalCost==0)) ? '¥'+basicInfoData.productTotalCost : '--' }}</strong>
  34. </div>
  35. </a-alert>
  36. <!-- 筛选条件 -->
  37. <div class="table-page-search-wrapper">
  38. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  39. <a-row :gutter="15">
  40. <a-col :md="6" :sm="24">
  41. <a-form-item label="产品编码" prop="productCode">
  42. <a-input id="chainTransferInEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  43. </a-form-item>
  44. </a-col>
  45. <a-col :md="6" :sm="24">
  46. <a-form-item label="产品名称" prop="productName">
  47. <a-input id="chainTransferInEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  48. </a-form-item>
  49. </a-col>
  50. <a-col :md="6" :sm="24">
  51. <a-form-item label="产品分类">
  52. <a-cascader
  53. @change="changeProductType"
  54. change-on-select
  55. v-model="productType"
  56. expand-trigger="hover"
  57. :options="productTypeList"
  58. :fieldNames="{ label: 'productTypeName', value: 'productTypeSn', children: 'children' }"
  59. id="chainTransferInEdit-productType"
  60. placeholder="请选择产品分类"
  61. allowClear />
  62. </a-form-item>
  63. </a-col>
  64. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  65. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="chainTransferInEdit-refresh">查询</a-button>
  66. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="chainTransferInEdit-reset">重置</a-button>
  67. </a-col>
  68. </a-row>
  69. </a-form>
  70. </div>
  71. <!-- 列表 -->
  72. <s-table
  73. class="sTable"
  74. ref="table"
  75. size="small"
  76. :rowKey="(record) => record.id"
  77. :columns="columns"
  78. :data="loadData"
  79. :defaultLoadData="false"
  80. bordered>
  81. <!-- 仓库仓位 -->
  82. <template slot="warehouse" slot-scope="text, record, index">
  83. <a-cascader
  84. size="small"
  85. @change="e => changeWarehouseCascade(e, record, index)"
  86. v-model="record.warehouseCascade"
  87. expand-trigger="hover"
  88. :allowClear="false"
  89. :options="warehouseCascadeData"
  90. :fieldNames="{ label: 'name', value: 'sn', children: 'warehouseLocationList' }"
  91. id="chainTransferInEdit-warehouseCascade"
  92. placeholder="请选择仓库仓位"
  93. style="width: 100%;" />
  94. </template>
  95. </s-table>
  96. </a-card>
  97. </a-spin>
  98. <div class="affix-cont">
  99. <a-button
  100. type="primary"
  101. id="chainTransferInEdit-submit"
  102. size="large"
  103. class="button-primary"
  104. :disabled="spinning"
  105. @click="handleSubmit"
  106. style="padding: 0 60px;">提交入库</a-button>
  107. </div>
  108. </div>
  109. </template>
  110. <script>
  111. import { commonMixin } from '@/utils/mixin'
  112. import { STable, VSelect } from '@/components'
  113. import { getOperationalPrecision } from '@/libs/tools.js'
  114. import { dealerProductTypeList } from '@/api/dealerProductType'
  115. import { warehouseCascadeList } from '@/api/warehouse'
  116. import { allocLinkagePutDetailSn, allocLinkagePutDetailList, allocLinkagePutDetailCount, allocLinkagePutDetailUpdate, allocLinkagePutSubmit, allocLinkagePutDetailPrint } from '@/api/allocLinkagePut'
  117. import Print from '@/views/common/print.vue'
  118. import { hdPrint } from '@/libs/JGPrint'
  119. export default {
  120. name: 'AllocLinkagePutEdit',
  121. components: { STable, VSelect, Print },
  122. mixins: [commonMixin],
  123. data () {
  124. return {
  125. spinning: false,
  126. queryParam: {
  127. productCode: '', // 产品编码
  128. productName: '', // 产品名称
  129. productTypeSn1: '', // 产品分类1
  130. productTypeSn2: '', // 产品分类2
  131. productTypeSn3: '' // 产品分类3
  132. },
  133. disabled: false, // 查询、重置按钮是否可操作
  134. productTypeList: [], // 产品分类 下拉数据
  135. productType: [],
  136. warehouseCascadeData: [], // 仓库仓位
  137. // 表头
  138. columns: [
  139. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  140. { title: '产品编码', dataIndex: 'productCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  141. { title: '产品名称', dataIndex: 'dealerProductEntity.name', width: '18%', align: 'left', customRender: function (text) { return text || '--' }, ellipsis: true },
  142. { title: '原厂编码', dataIndex: 'productOrigCode', width: '13%', align: 'center', customRender: function (text) { return text || '--' } },
  143. { title: '成本价', dataIndex: 'putCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  144. { title: '调入数量', dataIndex: 'putQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  145. { title: '单位', dataIndex: 'dealerProductEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  146. { title: '成本小计', dataIndex: 'costSubtotal', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  147. { title: '仓库仓位', scopedSlots: { customRender: 'warehouse' }, width: '16%', align: 'center' }
  148. ],
  149. // 加载数据方法 必须为 Promise 对象
  150. loadData: parameter => {
  151. this.disabled = true
  152. this.spinning = true
  153. const params = Object.assign(parameter, this.queryParam, { allocationLinkagePutSn: this.$route.params.sn })
  154. return allocLinkagePutDetailList(params).then(res => {
  155. let data
  156. if (res.status == 200) {
  157. data = res.data
  158. this.getDetailCount(params)
  159. const no = (data.pageNo - 1) * data.pageSize
  160. for (var i = 0; i < data.list.length; i++) {
  161. data.list[i].no = no + i + 1
  162. const warehouseSn = data.list[i].warehouseSn || undefined
  163. const warehouseLocationSn = data.list[i].warehouseLocationSn || undefined
  164. data.list[i].warehouseSnBackups = warehouseSn
  165. data.list[i].warehouseLocationSnBackups = warehouseLocationSn
  166. if (warehouseSn || warehouseLocationSn) {
  167. data.list[i].warehouseCascade = [warehouseSn, warehouseLocationSn]
  168. } else {
  169. data.list[i].warehouseCascade = undefined
  170. }
  171. // 成本小计 由于数据库内小数位数为4位,页面则需显示2位。因此会做小数运算精度处理
  172. data.list[i].costSubtotal = getOperationalPrecision(data.list[i].putCost, data.list[i].putQty)
  173. }
  174. this.localDataSource = data.list || []
  175. this.disabled = false
  176. }
  177. this.spinning = false
  178. return data
  179. })
  180. },
  181. localDataSource: [],
  182. basicInfoData: null, // 基本信息
  183. productTotal: null, // 合计
  184. printerType: 'NEEDLE' // 打印机类型
  185. }
  186. },
  187. methods: {
  188. // 重置
  189. resetSearchForm () {
  190. this.queryParam.productCode = ''
  191. this.queryParam.productName = ''
  192. this.queryParam.productTypeSn1 = ''
  193. this.queryParam.productTypeSn2 = ''
  194. this.queryParam.productTypeSn3 = ''
  195. this.productType = []
  196. this.$refs.table.refresh(true)
  197. },
  198. // 基本信息
  199. getDetail () {
  200. allocLinkagePutDetailSn({ sn: this.$route.params.sn }).then(res => {
  201. if (res.status == 200) {
  202. this.basicInfoData = res.data
  203. this.getProductType()
  204. } else {
  205. this.basicInfoData = null
  206. }
  207. })
  208. },
  209. // 提交
  210. handleSubmit () {
  211. this.spinning = true
  212. allocLinkagePutSubmit({ sn: this.$route.params.sn }).then(res => {
  213. if (res.status == 200) {
  214. this.$message.success(res.message)
  215. this.handleBack()
  216. this.spinning = false
  217. } else {
  218. this.spinning = false
  219. }
  220. })
  221. },
  222. // 合计
  223. getDetailCount (params) {
  224. allocLinkagePutDetailCount(params).then(res => {
  225. if (res.status == 200) {
  226. this.productTotal = res.data
  227. } else {
  228. this.productTotal = null
  229. }
  230. })
  231. },
  232. // 返回列表
  233. handleBack () {
  234. this.$router.push({ path: '/allocationManagement/chainTransferIn/list' })
  235. },
  236. // 产品分类 change
  237. changeProductType (val, opt) {
  238. this.queryParam.productTypeSn1 = val[0] ? val[0] : ''
  239. this.queryParam.productTypeSn2 = val[1] ? val[1] : ''
  240. this.queryParam.productTypeSn3 = val[2] ? val[2] : ''
  241. },
  242. changeWarehouseCascade (val, opt, ind) {
  243. if (val.length < 2) {
  244. this.$message.warning('当前仓库无仓位,请选择其他仓库')
  245. const warehouseSnBackups = this.localDataSource[ind].warehouseSnBackups || undefined
  246. const warehouseLocationSnBackups = this.localDataSource[ind].warehouseLocationSnBackups || undefined
  247. this.localDataSource[ind].warehouseSn = warehouseSnBackups
  248. this.localDataSource[ind].warehouseLocationSn = warehouseLocationSnBackups
  249. if (warehouseSnBackups || warehouseLocationSnBackups) {
  250. this.localDataSource[ind].warehouseCascade = [warehouseSnBackups, warehouseLocationSnBackups]
  251. } else {
  252. this.localDataSource[ind].warehouseCascade = undefined
  253. }
  254. } else {
  255. this.localDataSource[ind].warehouseSn = val[0] ? val[0] : ''
  256. this.localDataSource[ind].warehouseLocationSn = val[1] ? val[1] : ''
  257. this.handleAdd(this.localDataSource[ind])
  258. }
  259. },
  260. // 添加/编辑
  261. handleAdd (row) {
  262. // 清空成本价或数量时,值应保持未清空前的值,因成本价和数量都不可为空
  263. if (!row.warehouseSn) {
  264. row.warehouseSn = row.warehouseSnBackups
  265. return
  266. }
  267. if (!row.warehouseLocationSn) {
  268. row.warehouseLocationSn = row.warehouseLocationSnBackups
  269. return
  270. }
  271. const params = {
  272. id: row.id,
  273. warehouseLocationSn: row.warehouseLocationSn,
  274. warehouseSn: row.warehouseSn
  275. }
  276. this.spinning = true
  277. allocLinkagePutDetailUpdate(params).then(res => {
  278. if (res.status == 200) {
  279. this.$message.success(res.message)
  280. this.$refs.table.refresh()
  281. this.spinning = false
  282. } else {
  283. this.spinning = false
  284. }
  285. })
  286. },
  287. // 产品分类 列表
  288. getProductType () {
  289. dealerProductTypeList({ sysFlag: this.basicInfoData.allocationType == 'JIANGUAN' ? '1' : '0' }).then(res => {
  290. if (res.status == 200) {
  291. this.productTypeList = res.data
  292. } else {
  293. this.productTypeList = []
  294. }
  295. })
  296. },
  297. getWarehouseCascade () {
  298. warehouseCascadeList({}).then(res => {
  299. if (res.status == 200) {
  300. res.data.map(item => {
  301. item.sn = item.warehouseSn
  302. if (item.warehouseLocationList) {
  303. item.warehouseLocationList.map(subItem => {
  304. subItem.sn = subItem.warehouseLocationSn
  305. })
  306. }
  307. })
  308. this.warehouseCascadeData = res.data
  309. } else {
  310. this.warehouseCascadeData = []
  311. }
  312. })
  313. },
  314. // 打印预览/快捷打印
  315. handlePrint (type, printerType) {
  316. const _this = this
  317. _this.spinning = true
  318. const url = allocLinkagePutDetailPrint
  319. const params = { sn: this.$route.params.sn, type: printerType }
  320. // 打印或导出
  321. hdPrint(printerType, type, url, params, '', function () {
  322. _this.spinning = false
  323. })
  324. },
  325. pageInit () {
  326. this.getDetail()
  327. this.getWarehouseCascade()
  328. }
  329. },
  330. mounted () {
  331. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  332. this.pageInit()
  333. this.resetSearchForm()
  334. }
  335. },
  336. activated () {
  337. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  338. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  339. this.pageInit()
  340. this.resetSearchForm()
  341. }
  342. },
  343. beforeRouteEnter (to, from, next) {
  344. next(vm => {})
  345. }
  346. }
  347. </script>
  348. <style lang="less">
  349. .chainTransferInEdit-wrap{
  350. position: relative;
  351. height: 100%;
  352. padding-bottom: 51px;
  353. box-sizing: border-box;
  354. .chainTransferInEdit-back, .chainTransferInEdit-cont{
  355. margin-bottom: 10px;
  356. }
  357. >.ant-spin-nested-loading{
  358. overflow-y: auto;
  359. height: 100%;
  360. }
  361. }
  362. </style>