edit.vue 37 KB

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