edit.vue 38 KB

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