edit.vue 36 KB

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