edit.vue 36 KB

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