edit.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  1. <template>
  2. <div class="allocateBillEdit-wrap">
  3. <div class="ant-spin-nested-loading">
  4. <a-page-header :ghost="false" :backIcon="false" class="allocateBillEdit-back" >
  5. <!-- 自定义的二级文字标题 -->
  6. <template slot="subTitle">
  7. <a id="allocateBillEdit-back-btn" href="javascript:;" @click="handleBack"><a-icon type="left" /> 返回列表</a>
  8. </template>
  9. <!-- 操作区,位于 title 行的行尾 -->
  10. <template slot="extra">
  11. <a-button
  12. key="4"
  13. type="primary"
  14. class="button-info"
  15. v-if="$hasPermissions('B_transferOut_print')"
  16. id="allocateBillEdit-db-print-btn"
  17. :disabled="localDataSource.length==0"
  18. @click="handlePrint('dbPrint')">调拨打印</a-button>
  19. <a-button
  20. key="3"
  21. type="default"
  22. class="button-info"
  23. v-if="$hasPermissions('B_transferOutType_print')"
  24. id="allocateBillEdit-dbfl-print-btn"
  25. :disabled="localDataSource.length==0"
  26. @click="handlePrint('dbflPrint')">调拨分类打印</a-button>
  27. <a-divider type="vertical" />
  28. <a-button
  29. key="2"
  30. type="primary"
  31. class="button-info"
  32. v-if="$hasPermissions('B_transferOut_detail_export')"
  33. id="allocateBillDetail-export-btn"
  34. :disabled="localDataSource.length==0"
  35. @click="handleExcel('ALLOCATE_BILL','调拨明细')">导出Excel</a-button>
  36. <a-button
  37. key="1"
  38. type="default"
  39. class="button-info"
  40. v-if="$hasPermissions('B_transferOutType_export')"
  41. id="allocateBillDetail-export-btn"
  42. :disabled="localDataSource.length==0"
  43. @click="handlePrint('dbflExport')">调拨分类导出</a-button>
  44. </template>
  45. </a-page-header>
  46. <a-card size="small" :bordered="false" v-if="basicInfoData" class="allocateBillEdit-cont">
  47. <a-collapse :activeKey="['0']">
  48. <a-collapse-panel key="0" header="基础信息">
  49. <a-descriptions :column="3">
  50. <a-descriptions-item label="调往对象">{{ (basicInfoData&&basicInfoData.targetName) || '--' }}</a-descriptions-item>
  51. <a-descriptions-item label="发货编号">{{ (basicInfoData&&basicInfoData.sendNo) || '--' }}</a-descriptions-item>
  52. <a-descriptions-item label="收货客户名称">{{ (basicInfoData&&basicInfoData.receiverName) || '--' }}</a-descriptions-item>
  53. <a-descriptions-item label="调拨单号">{{ (basicInfoData&&basicInfoData.allocateNo) || '--' }}</a-descriptions-item>
  54. <a-descriptions-item label="业务状态">{{ (basicInfoData&&basicInfoData.stateDictValue) || '--' }}</a-descriptions-item>
  55. <a-descriptions-item label="打印状态">{{ (basicInfoData&&basicInfoData.printStateDictValue) || '--' }}</a-descriptions-item>
  56. </a-descriptions>
  57. <a-divider>以下信息可修改,请点击<span style="color: dodgerblue;font-size: 14px;cursor: pointer;" @click="editRemark = true" ><a-icon type="form" title="编辑基础信息" />编辑</span></a-divider>
  58. <a-descriptions :column="3">
  59. <a-descriptions-item label="费用类型">
  60. {{ (basicInfoData&&basicInfoData.costTypeName) || '--' }}
  61. </a-descriptions-item>
  62. <a-descriptions-item label="调拨类型">
  63. <div>
  64. <span v-if="basicInfoData.allocateSortName">{{ basicInfoData.allocateSortName || '--' }}</span>
  65. <span v-if="basicInfoData.allocateTypeName">/{{ basicInfoData.allocateTypeName || '--' }}</span>
  66. </div>
  67. </a-descriptions-item>
  68. <a-descriptions-item label="费用归属品牌">
  69. {{ (basicInfoData&&basicInfoData.productBrandName) || '--' }}
  70. </a-descriptions-item>
  71. <a-descriptions-item label="费用归属品类">
  72. <div>
  73. <span v-if="basicInfoData.productTypeName1">{{ basicInfoData.productTypeName1 || '--' }}</span>
  74. <span v-else>--</span>
  75. <span v-if="basicInfoData.productTypeName2">/{{ basicInfoData.productTypeName2 || '--' }}</span>
  76. <span v-if="basicInfoData.productTypeName3">/{{ basicInfoData.productTypeName3 || '--' }}</span>
  77. </div>
  78. </a-descriptions-item>
  79. <a-descriptions-item label="起止时间">
  80. <span v-if="basicInfoData&&(basicInfoData.promoStartDate || basicInfoData.promoEndDate)">{{ (basicInfoData&&basicInfoData.promoStartDate) || '--' }} ~ {{ (basicInfoData&&basicInfoData.promoEndDate) || '--' }}</span>
  81. <span v-else>--</span>
  82. </a-descriptions-item>
  83. <a-descriptions-item label="备注">
  84. {{ (basicInfoData&&basicInfoData.remark) }}
  85. </a-descriptions-item>
  86. </a-descriptions>
  87. </a-collapse-panel>
  88. </a-collapse>
  89. </a-card>
  90. <!-- 选择产品 -->
  91. <a-card size="small" :bordered="false" class="allocateBillEdit-cont">
  92. <a-collapse :activeKey="['1']">
  93. <a-collapse-panel key="1" :forceRender="true" header="选择产品">
  94. <!-- 筛选条件 -->
  95. <div class="table-page-search-wrapper">
  96. <a-form layout="inline" @keyup.enter.native="$refs.table.refresh(true)">
  97. <a-row :gutter="15">
  98. <a-col :md="6" :sm="24">
  99. <a-form-item label="产品编码" prop="productCode">
  100. <a-input id="allocateBillEdit-productCode" v-model.trim="queryParam.productCode" placeholder="请输入产品编码" allowClear />
  101. </a-form-item>
  102. </a-col>
  103. <a-col :md="6" :sm="24">
  104. <a-form-item label="产品名称" prop="productName">
  105. <a-input id="allocateBillEdit-productName" v-model.trim="queryParam.productName" placeholder="请输入产品名称" allowClear />
  106. </a-form-item>
  107. </a-col>
  108. <a-col :md="6" :sm="24">
  109. <a-form-item label="原厂编码" prop="productOrigCode">
  110. <a-input id="allocateBillEdit-productOrigCode" v-model.trim="queryParam.productOrigCode" placeholder="请输入原厂编码" allowClear />
  111. </a-form-item>
  112. </a-col>
  113. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  114. <a-button type="primary" @click="$refs.table.refresh(true)" :disabled="disabled" id="storeTransferOutList-refresh">查询</a-button>
  115. <a-button style="margin-left: 8px" @click="resetSearchForm" :disabled="disabled" id="storeTransferOutList-reset">重置</a-button>
  116. </a-col>
  117. </a-row>
  118. </a-form>
  119. </div>
  120. <!-- 列表 -->
  121. <s-table
  122. class="sTable"
  123. ref="table"
  124. size="small"
  125. index="0"
  126. tableId="table1"
  127. :rowKey="(record) => record.stockSn"
  128. :columns="columns"
  129. :customRow="handleClickRow"
  130. :data="loadData"
  131. :scroll="{ y: 300 }"
  132. bordered>
  133. <!-- 操作 -->
  134. <template slot="action1" slot-scope="text, record">
  135. <a-button
  136. size="small"
  137. type="link"
  138. class="button-primary"
  139. :loading="spinning"
  140. @click="handleAdd(record, false, 'noRefresh')"
  141. >添加</a-button>
  142. </template>
  143. </s-table>
  144. </a-collapse-panel>
  145. </a-collapse>
  146. </a-card>
  147. <!-- 已选产品 -->
  148. <a-card size="small" :bordered="false" class="allocateBillEdit-cont">
  149. <a-collapse :activeKey="['2']">
  150. <a-collapse-panel key="2" :forceRender="true" header="已选产品">
  151. <!-- 总计 -->
  152. <a-alert type="info" style="margin-bottom:10px">
  153. <div slot="message">
  154. 总数量:<strong>{{ (productTotal&&(productTotal.totalQty || productTotal.totalQty==0)) ? productTotal.totalQty : '--' }}</strong> ,
  155. <span v-if="$hasPermissions('B_isShowCost')">总成本(¥):<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? productTotal.totalCost : '--' }}</strong> ,</span>
  156. <span v-if="$hasPermissions('B_isShowPrice')">总售价(¥):<strong>{{ (productTotal&&(productTotal.totalPrice || productTotal.totalPrice==0)) ? productTotal.totalPrice : '--' }}</strong></span>
  157. </div>
  158. </a-alert>
  159. <!-- 筛选条件 -->
  160. <a-row :gutter="15">
  161. <a-col :span="16">
  162. <div class="table-page-search-wrapper">
  163. <a-form layout="inline" @keyup.enter.native="$refs.chooseTable.refresh(true)">
  164. <a-row :gutter="15">
  165. <a-col :md="9" :sm="24">
  166. <a-form-item label="产品编码" prop="productCode">
  167. <a-input id="allocateBillEdit-productCode" v-model.trim="chooseQueryParam.productCode" placeholder="请输入产品编码" allowClear />
  168. </a-form-item>
  169. </a-col>
  170. <a-col :md="9" :sm="24">
  171. <a-form-item label="产品名称" prop="productName">
  172. <a-input id="allocateBillEdit-productName" v-model.trim="chooseQueryParam.productName" placeholder="请输入产品名称" allowClear />
  173. </a-form-item>
  174. </a-col>
  175. <a-col :md="6" :sm="24" style="margin-bottom: 10px;">
  176. <a-button type="primary" @click="$refs.chooseTable.refresh(true)" :disabled="chooseDisabled" id="storeTransferOutList-refresh">查询</a-button>
  177. <a-button style="margin-left: 8px" @click="chooseResetSearchForm" :disabled="chooseDisabled" id="storeTransferOutList-reset">重置</a-button>
  178. </a-col>
  179. </a-row>
  180. </a-form>
  181. </div>
  182. </a-col>
  183. <a-col :span="8" style="text-align: right;">
  184. <span v-if="selNums">已选{{ selNums }}项</span>
  185. <a-button
  186. style="margin:0 15px;"
  187. size="small"
  188. id="salesEdit-plDel-btn"
  189. @click="openPlSet">批量设置费用归属</a-button>
  190. <a-button size="small" id="allocateBillEdit-import-btn" @click="openGuideModal=true">导入产品</a-button>
  191. <a-button size="small" type="danger" style="margin-left: 5px" @click.stop="handleDel('', 'all')" id="chainTransferOutEdit-del-all-btn">整单删除</a-button>
  192. </a-col>
  193. </a-row>
  194. <!-- 列表 -->
  195. <s-table
  196. class="sTable"
  197. ref="chooseTable"
  198. size="small"
  199. index="1"
  200. tableId="table2"
  201. :rowKey="(record) => record.id"
  202. :row-selection="{ columnWidth: 40 }"
  203. @rowSelection="rowSelectionFun"
  204. :columns="chooseColumns"
  205. :data="chooseLoadData"
  206. :scroll="{ y: 300 }"
  207. bordered>
  208. <!-- 售价 -->
  209. <template slot="price" slot-scope="text, record, index">
  210. <!-- 调往对象为经销商时不可编辑售价,为员工或其他时可编辑售价 -->
  211. <div v-if="$route.params.dealerLevel == 'OTHER'">
  212. <a-select
  213. size="small"
  214. id="allocateBillEdit-price"
  215. option-label-prop="label"
  216. v-model="record.price"
  217. placeholder="请选择"
  218. @change="e => priceChange(e, record)"
  219. @focus="e => priceFocus(record, index)"
  220. style="width: 100%;">
  221. <a-select-option v-if="record.cost" :value="record.cost" :key="'cb-'+record.cost" :label="record.cost">成本 {{ record.cost }}</a-select-option>
  222. <a-select-option v-if="loadDataSource&&loadDataSource[index]&&loadDataSource[index].provincePrice" :value="loadDataSource[index].provincePrice" :key="'A-'+loadDataSource[index].productSn" :label="loadDataSource[index].provincePrice">A价 {{ loadDataSource[index].provincePrice }}</a-select-option>
  223. <a-select-option v-if="loadDataSource&&loadDataSource[index]&&loadDataSource[index].cityPrice" :value="loadDataSource[index].cityPrice" :key="'B-'+loadDataSource[index].productSn" :label="loadDataSource[index].cityPrice">B价 {{ loadDataSource[index].cityPrice }}</a-select-option>
  224. <a-select-option v-if="loadDataSource&&loadDataSource[index]&&loadDataSource[index].specialPrice" :value="loadDataSource[index].specialPrice" :key="'C-'+loadDataSource[index].productSn" :label="loadDataSource[index].specialPrice">C价 {{ loadDataSource[index].specialPrice }}</a-select-option>
  225. </a-select>
  226. </div>
  227. <span v-else>{{ record.price }}</span>
  228. </template>
  229. <!-- 调出数量 -->
  230. <template slot="qty" slot-scope="text, record">
  231. <a-input-number
  232. size="small"
  233. id="allocateBillEdit-qty"
  234. v-model="record.qty"
  235. :precision="0"
  236. :min="1"
  237. :max="999999"
  238. placeholder="请输入"
  239. @blur="e => qtyBlur(e.target.value, record)"
  240. style="width: 100%;" />
  241. </template>
  242. <!-- 费用归属部门 -->
  243. <template slot="department" slot-scope="text, record">
  244. <a-select
  245. style="width:100%"
  246. placeholder="请选择部门"
  247. size="small"
  248. allowClear
  249. v-model="record.departmentSn"
  250. :showSearch="true"
  251. @change="e => handleChange(e, record)"
  252. option-filter-prop="children"
  253. :filter-option="filterOption">
  254. <a-select-option v-for="item in departmentList" :key="item.departmentSn" :value="item.departmentSn">{{ item.name }}</a-select-option>
  255. </a-select>
  256. </template>
  257. <!-- 操作 -->
  258. <template slot="action" slot-scope="text, record">
  259. <a-button
  260. size="small"
  261. type="link"
  262. class="button-error"
  263. :loading="spinning"
  264. @click="handleDel(record)"
  265. id="allocateBillEdit-del-btn">删除</a-button>
  266. </template>
  267. </s-table>
  268. </a-collapse-panel>
  269. </a-collapse>
  270. </a-card>
  271. </div>
  272. <div class="affix-cont" v-if="basicInfoData">
  273. <a-button
  274. type="primary"
  275. id="allocateBillEdit-submit"
  276. size="large"
  277. :loading="spinning"
  278. class="button-primary"
  279. @click="handleOpen"
  280. style="padding: 0 60px;">提交</a-button>
  281. </div>
  282. <!-- 导入产品 -->
  283. <importGuideModal :openModal="openGuideModal" :params="{allocateSn: $route.params.sn}" @close="openGuideModal=false" @ok="handleGuideOk" />
  284. <!-- 打印导出 -->
  285. <print-modal
  286. :openModal="openModal"
  287. :itemData="basicInfoData"
  288. :nowType="nowType"
  289. @export="exportFl"
  290. @ok="handleOk"
  291. @close="openModal=false" />
  292. <!-- 提交调拨单 -->
  293. <dsModal ref="dsModal" :dealerLevel="$route.params.dealerLevel" :openModal="showDsModal" @close="showDsModal=false" @ok="handleSubmit" />
  294. <!-- 编辑基础信息 -->
  295. <basic-info-modal :openModal="editRemark" :detailData="basicInfoData" @ok="getDetail" @close="editRemark=false" />
  296. <!-- 批量设置部门 -->
  297. <commonModal modalTit="批量设置费用归属部门" :openModal="showPlModal" @cancel="closePlSet" @ok="setPlSetOk">
  298. <div style="text-align: center;">
  299. <div style="margin-bottom: 15px;font-size: 14px;"><strong>请选择费用归属部门</strong></div>
  300. <div style="line-height: 24px;">
  301. <div>
  302. <a-select
  303. style="width:100%"
  304. placeholder="请选择部门"
  305. allowClear
  306. v-model="plSetVal"
  307. :showSearch="true"
  308. option-filter-prop="children"
  309. :filter-option="filterOption">
  310. <a-select-option v-for="item in departmentList" :key="item.departmentSn" :value="item.departmentSn">{{ item.name }}</a-select-option>
  311. </a-select></div>
  312. </div>
  313. </div>
  314. </commonModal>
  315. </div>
  316. </template>
  317. <script>
  318. import { commonMixin } from '@/utils/mixin'
  319. import { STable, VSelect } from '@/components'
  320. import ImportGuideModal from './importGuideModal.vue'
  321. import basicInfoModal from './basicInfoModal.vue'
  322. import printModal from './printModal.vue'
  323. import dsModal from './dsModal.vue'
  324. import commonModal from '@/views/common/commonModal.vue'
  325. import { printFun, exportExcel } from '@/libs/JGPrint.js'
  326. import { queryStockProductPage } from '@/api/stock'
  327. import { productPriceInfo } from '@/api/product'
  328. import { departmentQueryList } from '@/api/expenseManagement'
  329. import { allocateBillDetailList, allocateBillDetailCount, allocateBillDetail, allocateBillDetailSave, allocateBillSubmit, allocateBillDetailDel, allocateBillDetailDelAll, allocateBillDetailPrint, allocateBillBatchInsert, allocateBillDetailExcel, updateBatchDepartment } from '@/api/allocateBill'
  330. export default {
  331. name: 'TransferOutEdit',
  332. mixins: [commonMixin],
  333. components: { STable, VSelect, ImportGuideModal, printModal, dsModal, basicInfoModal, commonModal },
  334. data () {
  335. return {
  336. spinning: false,
  337. showDsModal: false,
  338. editRemark: false,
  339. showPlModal: false,
  340. queryParam: {
  341. productCode: '',
  342. productName: '',
  343. productOrigCode: ''
  344. },
  345. chooseQueryParam: {
  346. productCode: '',
  347. productName: ''
  348. },
  349. disabled: false, // 查询、重置按钮是否可操作
  350. loading: false,
  351. chooseDisabled: false, // 查询、重置按钮是否可操作
  352. advanced: false, // 高级搜索 展开/关闭
  353. productBrandList: [], // 产品品牌 下拉数据
  354. productTypeList: [], // 产品分类 下拉数据
  355. productType: [],
  356. warehouseList: [], // 仓库 下拉数据
  357. departmentList: [], // 部门列表
  358. // 加载数据方法 必须为 Promise 对象
  359. loadData: parameter => {
  360. this.disabled = true
  361. const dealerLevel = this.$route.params.dealerLevel == 'OTHER' ? undefined : this.$route.params.dealerLevel
  362. return queryStockProductPage(Object.assign(parameter, this.queryParam, { zeroQtyFlag: '0', dealerLevel: dealerLevel })).then(res => {
  363. const data = res.data
  364. const no = (data.pageNo - 1) * data.pageSize
  365. for (var i = 0; i < data.list.length; i++) {
  366. data.list[i].no = no + i + 1
  367. }
  368. this.loadDataSource = data.list || []
  369. this.disabled = false
  370. return data
  371. })
  372. },
  373. loadDataSource: [],
  374. localDataSource: [],
  375. // 加载数据方法 必须为 Promise 对象
  376. chooseLoadData: parameter => {
  377. this.chooseDisabled = true
  378. const params = Object.assign(parameter, this.chooseQueryParam, { allocateSn: this.$route.params.sn })
  379. return allocateBillDetailList(params).then(res => {
  380. const data = res.data
  381. const no = (data.pageNo - 1) * data.pageSize
  382. for (var i = 0; i < data.list.length; i++) {
  383. data.list[i].no = no + i + 1
  384. data.list[i].qtyBackups = data.list[i].qty
  385. data.list[i].priceBackups = data.list[i].price
  386. data.list[i].departmentSn = data.list[i].departmentSn || undefined
  387. }
  388. this.localDataSource = data.list || []
  389. this.chooseDisabled = false
  390. this.getDetailCount(params)
  391. return data
  392. })
  393. },
  394. productTotal: null, // 合计
  395. basicInfoData: null, // 基本信息
  396. openGuideModal: false, // 导入产品引导
  397. openModal: false,
  398. nowType: null,
  399. rowSelectionInfo: null,
  400. plSetVal: undefined
  401. }
  402. },
  403. computed: {
  404. selNums () {
  405. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  406. },
  407. columns () {
  408. const arr = [
  409. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  410. { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  411. { title: '产品名称', dataIndex: 'productName', align: 'center', width: '29%', customRender: function (text) { return text || '--' }, ellipsis: true },
  412. { title: '原厂编码', dataIndex: 'productOrigCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  413. // { title: '成本价', dataIndex: 'lastStockCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  414. // { title: '售价', dataIndex: 'productPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  415. { title: '库存数量', dataIndex: 'currentStockQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  416. { title: '单位', dataIndex: 'productUnit', width: '7%', align: 'center', customRender: function (text) { return text || '--' } },
  417. { title: '操作', scopedSlots: { customRender: 'action1' }, width: '10%', align: 'center' }
  418. ]
  419. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  420. arr.splice(4, 0, { title: '成本价', dataIndex: 'lastStockCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  421. }
  422. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  423. const ind = this.$hasPermissions('B_isShowCost') ? 5 : 4
  424. arr.splice(ind, 0, { title: '售价', dataIndex: 'productPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  425. }
  426. return arr
  427. },
  428. chooseColumns () {
  429. const arr = [
  430. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  431. { title: '产品编码', dataIndex: 'productEntity.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  432. { title: '产品名称', dataIndex: 'productEntity.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  433. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  434. // { title: '成本价', dataIndex: 'cost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  435. // { title: '售价', scopedSlots: { customRender: 'price' }, width: '10%', align: 'center' },
  436. { title: '库存数量', dataIndex: 'currentStockQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  437. { title: '调出数量', scopedSlots: { customRender: 'qty' }, width: '10%', align: 'center' },
  438. { title: '费用归属部门', scopedSlots: { customRender: 'department' }, width: '10%', align: 'center' },
  439. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  440. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  441. ]
  442. if (this.$hasPermissions('B_isShowCost')) { // 成本价权限
  443. arr.splice(4, 0, { title: '成本价', dataIndex: 'cost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } })
  444. }
  445. if (this.$hasPermissions('B_isShowPrice')) { // 售价权限
  446. const ind = this.$hasPermissions('B_isShowCost') ? 5 : 4
  447. arr.splice(ind, 0, { title: '售价', scopedSlots: { customRender: 'price' }, width: '10%', align: 'center' })
  448. }
  449. return arr
  450. }
  451. },
  452. methods: {
  453. filterOption (input, option) {
  454. return (
  455. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  456. )
  457. },
  458. // 获取部门数据
  459. getDepartmentList () {
  460. departmentQueryList({}).then(res => {
  461. if (res.status == 200) {
  462. this.departmentList = res.data
  463. } else {
  464. this.departmentList = []
  465. }
  466. })
  467. },
  468. // 表格选中项
  469. rowSelectionFun (obj) {
  470. this.rowSelectionInfo = obj || null
  471. },
  472. // 批量设置退货原因
  473. openPlSet () {
  474. if (this.selNums) {
  475. this.showPlModal = true
  476. } else {
  477. this.$message.warning('请先选择产品!')
  478. }
  479. },
  480. closePlSet () {
  481. this.showPlModal = false
  482. this.plSetVal = undefined
  483. },
  484. setPlSetOk () {
  485. if (!this.plSetVal) {
  486. this.$message.warning('请选择费用归属部门!')
  487. } else {
  488. const snList = []
  489. const arr = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  490. const department = this.departmentList.find(item => item.departmentSn == this.plSetVal)
  491. arr.map(item => {
  492. snList.push({
  493. 'allocateDetailSn': item.allocateDetailSn,
  494. 'departmentSn': this.plSetVal,
  495. 'departmentName': department ? department.name : ''
  496. })
  497. })
  498. this.showPlModal = false
  499. this.$message.loading('正在设置...', 0)
  500. updateBatchDepartment(snList).then(res => {
  501. if (res.status == 200) {
  502. this.closePlSet()
  503. this.refashPage()
  504. }
  505. this.$message.destroy()
  506. })
  507. }
  508. },
  509. // 重置
  510. resetSearchForm (flag) {
  511. this.queryParam.productCode = ''
  512. this.queryParam.productName = ''
  513. this.queryParam.productOrigCode = ''
  514. if (!flag) {
  515. this.$refs.table.refresh(true)
  516. }
  517. },
  518. // 双击快速添加
  519. handleClickRow (record) {
  520. return {
  521. on: {
  522. dblclick: (event) => {
  523. this.handleAdd(record, false, 'noRefresh')
  524. }
  525. }
  526. }
  527. },
  528. // 导入产品
  529. handleGuideOk (obj) {
  530. allocateBillBatchInsert(obj).then(res => {
  531. if (res.status == 200) {
  532. this.$refs.chooseTable.refresh(true)
  533. }
  534. })
  535. },
  536. // 已选产品 重置
  537. chooseResetSearchForm (flag) {
  538. this.chooseQueryParam.productCode = ''
  539. this.chooseQueryParam.productName = ''
  540. if (!flag) {
  541. this.$refs.chooseTable.refresh(true)
  542. }
  543. },
  544. // 添加/编辑
  545. handleAdd (row, isEdit, isRefresh) {
  546. const params = {
  547. id: isEdit ? row.id : undefined,
  548. allocateSn: this.$route.params.sn,
  549. cost: isEdit ? row.cost : row.lastStockCost,
  550. price: isEdit ? row.price : row.productPrice,
  551. qty: isEdit ? row.qty : 1, // 添加时调出数量默认为1
  552. productSn: row.productSn,
  553. departmentSn: row.departmentSn
  554. }
  555. if (isEdit) { // 编辑
  556. // 清空数量时,值应保持未清空前的值,因数量不可为空
  557. if (!row.qty) {
  558. row.qty = row.qtyBackups
  559. return
  560. }
  561. if (!row.price) {
  562. row.price = row.priceBackups
  563. return
  564. }
  565. }
  566. this.spinning = true
  567. allocateBillDetailSave(params).then(res => {
  568. if (res.status == 200) {
  569. this.$message.success(res.message)
  570. if (isRefresh != 'noRefresh') {
  571. this.$refs.table.refresh()
  572. }
  573. this.$refs.chooseTable.refresh()
  574. this.spinning = false
  575. } else {
  576. this.spinning = false
  577. }
  578. })
  579. },
  580. // 删除
  581. handleDel (row, isAll) {
  582. const _this = this
  583. const content = isAll ? '删除后不可恢复,确定要进行整单删除吗?' : '删除后不可恢复,确定要进行删除吗?'
  584. this.$confirm({
  585. title: '提示',
  586. content: content,
  587. centered: true,
  588. onOk () {
  589. if (isAll) { // 整单删除
  590. _this.spinning = true
  591. allocateBillDetailDelAll({ sn: _this.$route.params.sn }).then(res => {
  592. if (res.status == 200) {
  593. _this.$message.success(res.message)
  594. _this.refashPage()
  595. }
  596. _this.spinning = false
  597. })
  598. } else { // 单个删除
  599. _this.spinning = true
  600. allocateBillDetailDel({ id: row.id }).then(res => {
  601. if (res.status == 200) {
  602. _this.$message.success(res.message)
  603. _this.refashPage()
  604. }
  605. _this.spinning = false
  606. })
  607. }
  608. }
  609. })
  610. },
  611. // 提交
  612. handleOpen () {
  613. if (this.localDataSource.length) {
  614. // 待提交
  615. if (this.basicInfoData.state == 'WAIT_SUBMIT') {
  616. this.showDsModal = true
  617. }
  618. // 待审核或审核不通过时
  619. if (this.basicInfoData.state == 'AUDIT_REJECT' || this.basicInfoData.state == 'WAIT_AUDIT') {
  620. this.handleSubmit()
  621. }
  622. } else {
  623. this.$message.warning('请选择产品')
  624. }
  625. },
  626. handleSubmit (params) {
  627. const _this = this
  628. const data = Object.assign({ allocateSn: this.$route.params.sn }, params || {})
  629. _this.spinning = true
  630. _this.showDsModal = false
  631. allocateBillSubmit(data).then(res => {
  632. if (res.status == 200) {
  633. _this.$message.success(res.message)
  634. _this.handleBack()
  635. } else {
  636. _this.spinning = false
  637. }
  638. })
  639. },
  640. // 基本信息
  641. getDetail () {
  642. this.spinning = true
  643. allocateBillDetail({ sn: this.$route.params.sn }).then(res => {
  644. if (res.status == 200) {
  645. this.basicInfoData = res.data
  646. } else {
  647. this.basicInfoData = null
  648. }
  649. this.spinning = false
  650. })
  651. },
  652. // 合计
  653. getDetailCount (params) {
  654. allocateBillDetailCount({ allocateSn: this.$route.params.sn, ...params }).then(res => {
  655. if (res.status == 200) {
  656. this.productTotal = res.data
  657. } else {
  658. this.productTotal = null
  659. }
  660. })
  661. },
  662. // 返回列表
  663. handleBack () {
  664. this.$router.push({ path: '/allocationManagement/transferOut/list', query: { closeLastOldTab: true } })
  665. },
  666. // 已选产品 调出数量 blur
  667. qtyBlur (val, record) {
  668. // 光标移出,值发生改变再调用编辑接口
  669. if (val != record.qtyBackups) {
  670. this.handleAdd(record, 'edit', 'noRefresh')
  671. }
  672. },
  673. // 已选产品 修改部门
  674. handleChange (value, record) {
  675. const department = this.departmentList.find(item => item.departmentSn == record.departmentSn)
  676. record.departmentName = department ? department.name : ''
  677. this.handleAdd(record, 'edit', 'noRefresh')
  678. },
  679. // 已选产品 售价 change
  680. priceChange (val, record) {
  681. // 光标移出,值发生改变再调用编辑接口
  682. if (val != record.priceBackups) {
  683. this.handleAdd(record, 'edit', 'noRefresh')
  684. }
  685. },
  686. // 获取价格
  687. priceFocus (row, index) {
  688. if (row.productSn) {
  689. productPriceInfo({ sn: row.productSn }).then(res => {
  690. if (res.status == 200 && res.data) {
  691. this.loadDataSource[index].provincePrice = res.data.provincePrice || undefined
  692. this.loadDataSource[index].cityPrice = res.data.cityPrice || undefined
  693. this.loadDataSource[index].specialPrice = res.data.specialPrice || undefined
  694. }
  695. })
  696. }
  697. },
  698. // 导出
  699. handleExcel (printType, filename, data) {
  700. const _this = this
  701. this.spinning = true
  702. const params = { allocateSn: this.outBizSn || this.$route.params.sn, printType: printType, ...data }
  703. params.showCostFlag = this.$hasPermissions('B_isShowCost')
  704. params.showAmountFlag = this.$hasPermissions('B_isShowPrice')
  705. exportExcel(allocateBillDetailExcel, params, filename, function () {
  706. _this.spinning = false
  707. })
  708. },
  709. exportFl (data) {
  710. this.handleExcel(data.printType, '调拨分类', data)
  711. },
  712. // 打印预览/快捷打印
  713. handlePrint (type) {
  714. this.nowType = type
  715. this.openModal = true
  716. },
  717. handleOk (objs) {
  718. const _this = this
  719. const params = JSON.parse(JSON.stringify(objs))
  720. delete params.type
  721. _this.spinning = true
  722. const taskName = this.nowType == 'dbPrint' ? '调拨' : '调拨分类'
  723. printFun(
  724. allocateBillDetailPrint,
  725. params,
  726. objs.isPreview ? 'preview' : 'print',
  727. taskName,
  728. (res) => {
  729. _this.$message.info(res.message)
  730. _this.spinning = false
  731. },
  732. {
  733. billType: 'ALLOCATE',
  734. billSn: objs.allocateSn,
  735. billNo: objs.allocateNo,
  736. printType: taskName + '打印'
  737. }, !this.basicInfoData.printState || this.basicInfoData.printState == 'UNABLE_PRINT' || this.basicInfoData.printState == 'CANCEL_PRINT')
  738. },
  739. // 刷新当前页面
  740. refashPage () {
  741. // this.$refs.table.refresh()
  742. this.$refs.chooseTable.clearSelected()
  743. this.$refs.chooseTable.refresh()
  744. },
  745. pageInit () {
  746. this.getDepartmentList()
  747. this.getDetail()
  748. // this.resetSearchForm(1)
  749. // this.chooseResetSearchForm(1)
  750. }
  751. },
  752. mounted () {
  753. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  754. this.pageInit()
  755. }
  756. },
  757. activated () {
  758. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  759. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  760. this.pageInit()
  761. }
  762. },
  763. beforeRouteEnter (to, from, next) {
  764. next(vm => {})
  765. }
  766. }
  767. </script>
  768. <style lang="less">
  769. .allocateBillEdit-wrap{
  770. position: relative;
  771. height: 100%;
  772. box-sizing: border-box;
  773. > .ant-spin-nested-loading {
  774. position: relative;
  775. height: 100%;
  776. overflow: auto;
  777. padding-bottom: 50px;
  778. }
  779. .allocateBillEdit-back{
  780. margin-bottom: 10px;
  781. }
  782. .allocateBillEdit-cont{
  783. margin-bottom: 10px;
  784. .sub-title{
  785. font-size: 12px;
  786. color: #808695;
  787. margin-left: 10px;
  788. }
  789. .tag-txt{
  790. font-size: 12px;
  791. color: #ed1c24;
  792. }
  793. .edit-circle-btn{
  794. margin-left: 15px;
  795. i{
  796. vertical-align: text-bottom;
  797. }
  798. }
  799. .import-btn{
  800. margin-left: 15px;
  801. }
  802. }
  803. }
  804. </style>