edit.vue 16 KB

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