edit.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842
  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.attachmentList&&basicInfoData.attachmentList.length">
  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.attachmentList"
  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('M_transferOut_edit_costPrice')">总成本:<strong>{{ (productTotal&&(productTotal.totalCost || productTotal.totalCost==0)) ? toThousands(productTotal.totalCost) : '--' }}</strong> ,</span>
  180. <span v-if="$hasPermissions('M_transferOut_edit_salesPrice')">总售价:<strong>{{ (productTotal&&(productTotal.totalPrice || productTotal.totalPrice==0)) ? toThousands(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. departmentList: [], // 部门列表
  378. // 加载数据方法 必须为 Promise 对象
  379. loadData: parameter => {
  380. this.disabled = true
  381. const dealerLevel = this.$route.params.dealerLevel == 'OTHER' ? undefined : this.$route.params.dealerLevel
  382. return queryStockProductPage(Object.assign(parameter, this.queryParam, { zeroQtyFlag: '0', dealerLevel: dealerLevel })).then(res => {
  383. const data = res.data
  384. const no = (data.pageNo - 1) * data.pageSize
  385. for (var i = 0; i < data.list.length; i++) {
  386. data.list[i].no = no + i + 1
  387. data.list[i].qty = 1
  388. }
  389. this.loadDataSource = data.list || []
  390. this.disabled = false
  391. return data
  392. })
  393. },
  394. loadDataSource: [],
  395. localDataSource: [],
  396. // 加载数据方法 必须为 Promise 对象
  397. chooseLoadData: parameter => {
  398. this.chooseDisabled = true
  399. const params = Object.assign(parameter, this.chooseQueryParam, { allocateSn: this.$route.params.sn })
  400. return allocateBillDetailList(params).then(res => {
  401. const data = res.data
  402. const no = (data.pageNo - 1) * data.pageSize
  403. for (var i = 0; i < data.list.length; i++) {
  404. data.list[i].no = no + i + 1
  405. data.list[i].qtyBackups = data.list[i].qty
  406. data.list[i].priceBackups = data.list[i].price
  407. data.list[i].departmentSn = data.list[i].departmentSn || undefined
  408. }
  409. this.localDataSource = data.list || []
  410. this.chooseDisabled = false
  411. this.getDetailCount(params)
  412. return data
  413. })
  414. },
  415. productTotal: null, // 合计
  416. basicInfoData: null, // 基本信息
  417. openGuideModal: false, // 导入产品引导
  418. openModal: false,
  419. nowType: null,
  420. rowSelectionInfo: null,
  421. plSetVal: undefined
  422. }
  423. },
  424. computed: {
  425. selNums () {
  426. return this.rowSelectionInfo && this.rowSelectionInfo.selectedRowKeys.length || 0
  427. },
  428. columns () {
  429. const _this = this
  430. const arr = [
  431. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  432. { title: '产品编码', dataIndex: 'productCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  433. { title: '产品名称', dataIndex: 'productName', align: 'center', width: '26%', customRender: function (text) { return text || '--' }, ellipsis: true },
  434. { title: '原厂编码', dataIndex: 'productOrigCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  435. // { title: '成本价', dataIndex: 'lastStockCost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  436. // { title: '售价', dataIndex: 'productPrice', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  437. { title: '库存数量', dataIndex: 'currentStockQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  438. { title: '调出数量', scopedSlots: { customRender: 'qty' }, width: '8%', align: 'center' },
  439. { title: '单位', dataIndex: 'productUnit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  440. { title: '操作', scopedSlots: { customRender: 'action1' }, width: '10%', align: 'center' }
  441. ]
  442. if (this.$hasPermissions('M_transferOut_edit_costPrice')) { // 成本价权限
  443. arr.splice(4, 0, { title: '成本价', dataIndex: 'lastStockCost', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  444. }
  445. if (this.$hasPermissions('M_transferOut_edit_salesPrice')) { // 售价权限
  446. const ind = this.$hasPermissions('M_transferOut_edit_costPrice') ? 5 : 4
  447. arr.splice(ind, 0, { title: '售价', dataIndex: 'productPrice', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  448. }
  449. return arr
  450. },
  451. chooseColumns () {
  452. const _this = this
  453. const arr = [
  454. { title: '序号', dataIndex: 'no', width: '4%', align: 'center' },
  455. { title: '产品编码', dataIndex: 'productEntity.code', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  456. { title: '产品名称', dataIndex: 'productEntity.name', width: '20%', align: 'center', customRender: function (text) { return text || '--' }, ellipsis: true },
  457. { title: '原厂编码', dataIndex: 'productEntity.origCode', width: '10%', align: 'center', customRender: function (text) { return text || '--' } },
  458. // { title: '成本价', dataIndex: 'cost', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  459. // { title: '售价', scopedSlots: { customRender: 'price' }, width: '10%', align: 'center' },
  460. { title: '库存数量', dataIndex: 'currentStockQty', width: '10%', align: 'center', customRender: function (text) { return ((text || text == 0) ? text : '--') } },
  461. { title: '调出数量', scopedSlots: { customRender: 'qty' }, width: '10%', align: 'center' },
  462. { title: '费用归属部门', scopedSlots: { customRender: 'department' }, width: '10%', align: 'center' },
  463. { title: '单位', dataIndex: 'productEntity.unit', width: '6%', align: 'center', customRender: function (text) { return text || '--' } },
  464. { title: '操作', scopedSlots: { customRender: 'action' }, width: '6%', align: 'center' }
  465. ]
  466. if (this.$hasPermissions('M_transferOut_edit_costPrice')) { // 成本价权限
  467. arr.splice(4, 0, { title: '成本价', dataIndex: 'cost', width: '10%', align: 'right', customRender: function (text) { return ((text || text == 0) ? _this.toThousands(text) : '--') } })
  468. }
  469. if (this.$hasPermissions('M_transferOut_edit_salesPrice')) { // 售价权限
  470. const ind = this.$hasPermissions('M_transferOut_edit_costPrice') ? 5 : 4
  471. arr.splice(ind, 0, { title: '售价', scopedSlots: { customRender: 'price' }, width: '10%', align: 'right' })
  472. }
  473. return arr
  474. }
  475. },
  476. methods: {
  477. filterOption (input, option) {
  478. return (
  479. option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
  480. )
  481. },
  482. // 获取部门数据
  483. getDepartmentList () {
  484. departmentQueryList({}).then(res => {
  485. if (res.status == 200) {
  486. this.departmentList = res.data
  487. } else {
  488. this.departmentList = []
  489. }
  490. })
  491. },
  492. // 表格选中项
  493. rowSelectionFun (obj) {
  494. this.rowSelectionInfo = obj || null
  495. },
  496. // 批量设置退货原因
  497. openPlSet () {
  498. if (this.selNums) {
  499. this.showPlModal = true
  500. } else {
  501. this.$message.warning('请先选择产品!')
  502. }
  503. },
  504. closePlSet () {
  505. this.showPlModal = false
  506. this.plSetVal = undefined
  507. },
  508. setPlSetOk () {
  509. if (!this.plSetVal) {
  510. this.$message.warning('请选择费用归属部门!')
  511. } else {
  512. const snList = []
  513. const arr = this.rowSelectionInfo && this.rowSelectionInfo.selectedRows || []
  514. const department = this.departmentList.find(item => item.departmentSn == this.plSetVal)
  515. arr.map(item => {
  516. snList.push({
  517. 'allocateDetailSn': item.allocateDetailSn,
  518. 'departmentSn': this.plSetVal,
  519. 'departmentName': department ? department.name : ''
  520. })
  521. })
  522. this.showPlModal = false
  523. this.$message.loading('正在设置...', 0)
  524. updateBatchDepartment(snList).then(res => {
  525. if (res.status == 200) {
  526. this.closePlSet()
  527. this.refashPage()
  528. }
  529. this.$message.destroy()
  530. })
  531. }
  532. },
  533. // 重置
  534. resetSearchForm (flag) {
  535. this.queryParam.productCode = ''
  536. this.queryParam.productName = ''
  537. this.queryParam.productOrigCode = ''
  538. if (!flag) {
  539. this.$refs.table.refresh(true)
  540. }
  541. },
  542. // 双击快速添加
  543. handleClickRow (record) {
  544. return {
  545. on: {
  546. dblclick: (event) => {
  547. this.handleAdd(record, false, 'noRefresh')
  548. }
  549. }
  550. }
  551. },
  552. // 导入产品
  553. handleGuideOk (obj) {
  554. allocateBillBatchInsert(obj).then(res => {
  555. if (res.status == 200) {
  556. this.$refs.chooseTable.refresh(true)
  557. }
  558. })
  559. },
  560. // 已选产品 重置
  561. chooseResetSearchForm (flag) {
  562. this.chooseQueryParam.productCode = ''
  563. this.chooseQueryParam.productName = ''
  564. if (!flag) {
  565. this.$refs.chooseTable.refresh(true)
  566. }
  567. },
  568. // 添加/编辑
  569. handleAdd (row, isEdit, isRefresh) {
  570. const params = {
  571. id: isEdit ? row.id : undefined,
  572. allocateSn: this.$route.params.sn,
  573. cost: isEdit ? row.cost : row.lastStockCost,
  574. price: isEdit ? row.price : row.productPrice,
  575. qty: row.qty, // 添加时调出数量默认为1
  576. productSn: row.productSn,
  577. departmentSn: row.departmentSn,
  578. departmentName: row.departmentName
  579. }
  580. if (isEdit) { // 编辑
  581. // 清空数量时,值应保持未清空前的值,因数量不可为空
  582. if (!row.qty) {
  583. row.qty = row.qtyBackups
  584. return
  585. }
  586. if (!row.price) {
  587. row.price = row.priceBackups
  588. return
  589. }
  590. } else {
  591. if (!row.qty) {
  592. this.$message.info('请输入调出数量')
  593. return
  594. }
  595. }
  596. this.spinning = true
  597. allocateBillDetailSave(params).then(res => {
  598. if (res.status == 200) {
  599. this.$message.success(res.message)
  600. if (isRefresh != 'noRefresh') {
  601. this.$refs.table.refresh()
  602. }
  603. this.$refs.chooseTable.refresh()
  604. this.$refs.chooseTable.clearSelected()
  605. this.spinning = false
  606. } else {
  607. this.spinning = false
  608. }
  609. })
  610. },
  611. // 删除
  612. handleDel (row, isAll) {
  613. const _this = this
  614. const content = isAll ? '删除后不可恢复,确定要进行整单删除吗?' : '删除后不可恢复,确定要进行删除吗?'
  615. this.$confirm({
  616. title: '提示',
  617. content: content,
  618. centered: true,
  619. onOk () {
  620. if (isAll) { // 整单删除
  621. _this.spinning = true
  622. allocateBillDetailDelAll({ sn: _this.$route.params.sn }).then(res => {
  623. if (res.status == 200) {
  624. _this.$message.success(res.message)
  625. _this.refashPage()
  626. }
  627. _this.spinning = false
  628. })
  629. } else { // 单个删除
  630. _this.spinning = true
  631. allocateBillDetailDel({ id: row.id }).then(res => {
  632. if (res.status == 200) {
  633. _this.$message.success(res.message)
  634. _this.refashPage()
  635. }
  636. _this.spinning = false
  637. })
  638. }
  639. }
  640. })
  641. },
  642. // 提交
  643. handleOpen () {
  644. if (this.localDataSource.length) {
  645. // 待提交
  646. if (this.basicInfoData.state == 'WAIT_SUBMIT' && !this.basicInfoData.sendNo) {
  647. this.showDsModal = true
  648. } else {
  649. this.handleSubmit()
  650. }
  651. } else {
  652. this.$message.warning('请选择产品')
  653. }
  654. },
  655. handleSubmit (params) {
  656. const _this = this
  657. const data = Object.assign({ allocateSn: this.$route.params.sn }, params || {})
  658. _this.spinning = true
  659. _this.showDsModal = false
  660. allocateBillSubmit(data).then(res => {
  661. if (res.status == 200) {
  662. _this.$message.success(res.message)
  663. _this.handleBack()
  664. } else {
  665. _this.spinning = false
  666. }
  667. })
  668. },
  669. // 基本信息
  670. getDetail () {
  671. this.spinning = true
  672. allocateBillDetail({ sn: this.$route.params.sn }).then(res => {
  673. if (res.status == 200) {
  674. this.basicInfoData = res.data
  675. } else {
  676. this.basicInfoData = null
  677. }
  678. this.spinning = false
  679. })
  680. },
  681. // 合计
  682. getDetailCount (params) {
  683. allocateBillDetailCount({ allocateSn: this.$route.params.sn, ...params }).then(res => {
  684. if (res.status == 200) {
  685. this.productTotal = res.data
  686. } else {
  687. this.productTotal = null
  688. }
  689. })
  690. },
  691. // 返回列表
  692. handleBack () {
  693. this.$router.push({ path: '/allocationManagement/transferOut/list', query: { closeLastOldTab: true } })
  694. },
  695. // 已选产品 调出数量 blur
  696. qtyBlur (val, record) {
  697. // 光标移出,值发生改变再调用编辑接口
  698. if (val != record.qtyBackups) {
  699. this.handleAdd(record, 'edit', 'noRefresh')
  700. }
  701. },
  702. // 已选产品 修改部门
  703. handleChange (value, record) {
  704. if (value) {
  705. const department = this.departmentList.find(item => item.departmentSn == record.departmentSn)
  706. record.departmentName = department ? department.name : ''
  707. } else {
  708. record.departmentSn = ''
  709. record.departmentName = ''
  710. }
  711. this.handleAdd(record, 'edit', 'noRefresh')
  712. },
  713. // 已选产品 售价 change
  714. priceChange (val, record) {
  715. // 光标移出,值发生改变再调用编辑接口
  716. if (val != record.priceBackups) {
  717. this.handleAdd(record, 'edit', 'noRefresh')
  718. }
  719. },
  720. // 获取价格
  721. priceFocus (row, index) {
  722. if (row.productSn) {
  723. productPriceInfo({ sn: row.productSn }).then(res => {
  724. if (res.status == 200 && res.data) {
  725. this.loadDataSource[index].provincePrice = res.data.provincePrice || undefined
  726. this.loadDataSource[index].cityPrice = res.data.cityPrice || undefined
  727. this.loadDataSource[index].specialPrice = res.data.specialPrice || undefined
  728. }
  729. })
  730. }
  731. },
  732. // 导出
  733. handleExcel (printType, filename, data) {
  734. const _this = this
  735. this.spinning = true
  736. const params = { allocateSn: this.outBizSn || this.$route.params.sn, printType: printType, ...data }
  737. exportExcel(allocateBillDetailExcel, params, filename, function () {
  738. _this.spinning = false
  739. _this.$store.state.app.curActionPermission = ''
  740. })
  741. },
  742. exportFl (data) {
  743. this.handleExcel(data.printType, '调拨分类', data)
  744. },
  745. // 打印预览/快捷打印
  746. handlePrint (type) {
  747. this.nowType = type
  748. this.openModal = true
  749. },
  750. handleOk (objs) {
  751. const _this = this
  752. const params = JSON.parse(JSON.stringify(objs))
  753. delete params.type
  754. const taskName = this.nowType == 'dbPrint' ? '调拨' : '调拨分类'
  755. _this.spinning = true
  756. printFun(
  757. allocateBillDetailPrint,
  758. params,
  759. objs.isPreview ? 'preview' : 'print',
  760. taskName,
  761. (res) => {
  762. _this.spinning = false
  763. _this.$store.state.app.curActionPermission = ''
  764. },
  765. {
  766. billType: 'ALLOCATE',
  767. billSn: objs.allocateSn,
  768. billNo: objs.allocateNo,
  769. printType: taskName + '打印'
  770. }, !this.basicInfoData.printState || this.basicInfoData.printState == 'UNABLE_PRINT' || this.basicInfoData.printState == 'CANCEL_PRINT')
  771. },
  772. // 刷新当前页面
  773. refashPage () {
  774. // this.$refs.table.refresh()
  775. this.$refs.chooseTable.clearSelected()
  776. this.$refs.chooseTable.refresh()
  777. },
  778. pageInit () {
  779. this.getDepartmentList()
  780. this.getDetail()
  781. // this.resetSearchForm(1)
  782. // this.chooseResetSearchForm(1)
  783. }
  784. },
  785. mounted () {
  786. if (!this.$store.state.app.isNewTab) { // 页签刷新时调用
  787. this.pageInit()
  788. }
  789. },
  790. activated () {
  791. // 如果是新页签打开或者进入新的子页(例:存在列表第2条数据编辑页页签时再打开第4条数据的编辑页),则重置当前页面
  792. if (this.$store.state.app.isNewTab || !this.$store.state.app.isNewSubTab) {
  793. this.pageInit()
  794. }
  795. },
  796. beforeRouteEnter (to, from, next) {
  797. next(vm => {})
  798. }
  799. }
  800. </script>
  801. <style lang="less">
  802. .allocateBillEdit-wrap{
  803. position: relative;
  804. height: 100%;
  805. box-sizing: border-box;
  806. > .ant-spin-nested-loading {
  807. position: relative;
  808. height: 100%;
  809. overflow: auto;
  810. padding-bottom: 50px;
  811. }
  812. .allocateBillEdit-back{
  813. margin-bottom: 10px;
  814. }
  815. .allocateBillEdit-cont{
  816. margin-bottom: 10px;
  817. .sub-title{
  818. font-size: 12px;
  819. color: #808695;
  820. margin-left: 10px;
  821. }
  822. .tag-txt{
  823. font-size: 12px;
  824. color: #ed1c24;
  825. }
  826. .edit-circle-btn{
  827. margin-left: 15px;
  828. i{
  829. vertical-align: text-bottom;
  830. }
  831. }
  832. .import-btn{
  833. margin-left: 15px;
  834. }
  835. }
  836. }
  837. </style>