edit.vue 40 KB

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