edit.vue 38 KB

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