goodsInventoryLossAdd.vue 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785
  1. <template>
  2. <div class="bg-in-stock">
  3. <el-form ref="goodsInventoryAddForm" :model="goodsInventoryAddForm" :rules="goodsInventoryAddFormRule"
  4. label-width="120px" inline class="change-form">
  5. <h3 style="width: 100%;">库存报损</h3>
  6. <el-form-item label="报损时间" prop="report_time" class="change-form-item">
  7. <span v-if="type == 'detail'">{{ goodsInventoryAddForm.report_time }}</span>
  8. <el-date-picker v-else v-model="goodsInventoryAddForm.report_time" value-format="yyyy-MM-dd HH:mm:ss"
  9. type="datetime" :disabled="type === 'detail' || type === 'audit' || type === 'edit'" placeholder="选择日期时间">
  10. </el-date-picker>
  11. </el-form-item>
  12. <!-- <el-form-item label="所属部门" prop="dept_id" class="change-form-item">
  13. <el-cascader v-model="goodsInventoryAddForm.dept_id" :options="deptList"
  14. :disabled="type === 'detail' || type === 'audit'" :props="{
  15. label: 'name',
  16. value: 'id',
  17. emitPath: false,
  18. checkStrictly: true
  19. }" clearable @change="changewarehouseList"></el-cascader>
  20. </el-form-item> -->
  21. <el-form-item label="仓库" prop="warehouse_id" class="change-form-item">
  22. <span v-if="type == 'detail'">{{ getWarehouse(goodsInventoryAddForm.warehouse_id) }}</span>
  23. <el-select v-else v-model="goodsInventoryAddForm.warehouse_id" @change="cleanGoodsList"
  24. :disabled="type === 'detail' || type === 'audit' || type === 'edit'">
  25. <el-option v-for="item in warehouseList" :key="item.id" :label="item.name" :value="item.id" />
  26. </el-select>
  27. </el-form-item>
  28. <el-form-item label="报损类型" prop="damage_type_value" class="change-form-item">
  29. <span v-if="type == 'detail'">{{ getRoleSplit(goodsInventoryAddForm.damage_type_value) }}</span>
  30. <el-select v-else v-model="goodsInventoryAddForm.damage_type_value"
  31. :disabled="type === 'detail' || type === 'audit' || type === 'edit'">
  32. <el-option v-for="item in roleSplit" :key="item.label" :label="item.label" :value="item.value" />
  33. </el-select>
  34. </el-form-item>
  35. <el-form-item label="制单人" prop="creator_id" class="change-form-item">
  36. <span v-if="type == 'detail'">{{ getadminList(goodsInventoryAddForm.creator_id) }}</span>
  37. <el-select v-else v-model="goodsInventoryAddForm.creator_id"
  38. :disabled="type === 'detail' || type === 'audit' || type === 'edit'" @change="changeCreator">
  39. <el-option v-for="item in adminList" :key="item.id" :label="item.real_name" :value="item.id" />
  40. </el-select>
  41. </el-form-item>
  42. <el-form-item label="报损说明" prop="report_desc" class="change-form-item" style="width: 61%;">
  43. <span v-if="type == 'detail'">{{ goodsInventoryAddForm.report_desc }}</span>
  44. <el-input v-else style="flex: 1;" v-model="goodsInventoryAddForm.report_desc" type="textarea"
  45. :disabled="type === 'detail' || type === 'audit' || type === 'edit'" :autosize="{ minRows: 3, maxRows: 4 }"
  46. placeholder="请输入报损说明"></el-input>
  47. </el-form-item>
  48. <div class="mx">
  49. <h3>报损商品明细</h3>
  50. <el-button v-if="type !== 'edit' && type !== 'audit' && type !== 'detail'" class="button" size="mini"
  51. type="primary" @click="scanCode">录入SKU</el-button>
  52. <el-button v-if="type !== 'detail'" class="button" size="mini" type="primary"
  53. @click="handleSelectWarehouseEntryBatch">选择</el-button>
  54. </div>
  55. <div style="width: 100%; display: block;">
  56. <el-form-item style="width: 100%;">
  57. <el-table :data="goodsInventoryAddForm.product_list" border :cell-style="{ textAlign: 'center' }"
  58. :header-cell-style="{ textAlign: 'center' }" style="width: 100%; margin-top: 20px;">
  59. <!-- <el-table-column label="入库单号">
  60. <template slot-scope="scope">
  61. {{ scope.row.stock_sn }}
  62. </template>
  63. </el-table-column> -->
  64. <el-table-column label="商品编号">
  65. <template slot-scope="scope">
  66. <span v-if="id"> {{ scope.row.goods_vo.sn }}</span>
  67. <span v-else>{{ scope.row.goods_vo.sn }}</span>
  68. </template>
  69. </el-table-column>
  70. <el-table-column label="商品名称">
  71. <template slot-scope="scope">
  72. <span v-if="id">{{ scope.row.goods_vo.name }}</span>
  73. <span v-else>{{ scope.row.goods_vo.name }}</span>
  74. </template>
  75. </el-table-column>
  76. <el-table-column label="sku">
  77. <template slot-scope="scope">
  78. <span>{{ scope.row.product_vo.sku }}</span>
  79. </template>
  80. </el-table-column>
  81. <el-table-column label="序列号" v-if="sn_code_list">
  82. <template slot-scope="scope">
  83. <div class="sn-code-container">
  84. <span v-for="item in scope.row.sn_code_list" :key="item.id">
  85. <p>{{ item.sn_code }}</p>
  86. </span>
  87. </div>
  88. </template>
  89. </el-table-column>
  90. <el-table-column prop="product_vo.spec_name" label="规格型号">
  91. <!-- <template slot-scope="scope">
  92. <span v-if="!id">{{ scope.row.product_vo.spec_name.join("/") }}</span>
  93. <span v-else>{{ scope.row.product_vo.spec_name.join("/") }}</span>
  94. </template> -->
  95. </el-table-column>
  96. <el-table-column label="单位">
  97. <template slot-scope="scope">
  98. <span v-if="!id"> {{ scope.row.product_vo.unit }}</span>
  99. <span v-else> {{ scope.row.product_vo.unit }}</span>
  100. </template>
  101. </el-table-column>
  102. <el-table-column label="库存数量">
  103. <template slot-scope="scope">
  104. {{ scope.row.usable_stock }}
  105. </template>
  106. </el-table-column>
  107. <!-- <el-table-column label="调整类型">
  108. <template slot-scope="scope">
  109. <el-select :disabled="type === 'detail' || type === 'audit'" v-model="scope.row.type" placeholder="请选择调整类型">
  110. <el-option label="增加" :value="0" />
  111. <el-option label="减少" :value="1" />
  112. </el-select>
  113. </template>
  114. </el-table-column> -->
  115. <el-table-column label="报损数量">
  116. <template slot-scope="scope">
  117. <span v-if="type == 'edit'">{{ scope.row.num }}</span>
  118. <el-input v-else v-model="scope.row.report_num" type="number" :min="0" :maxlength="20"
  119. :disabled="type === 'detail' || type === 'audit'"></el-input>
  120. </template>
  121. </el-table-column>
  122. <!-- <el-table-column label="录入数量" >
  123. <template slot-scope="scope">
  124. <span>{{ scope.row.report_num }}</span>
  125. </template>
  126. </el-table-column> -->
  127. <!-- <el-table-column label="调整说明">
  128. <template slot-scope="scope">
  129. <el-input v-model="scope.row.report_remark" :min="0" :maxlength="50"
  130. :disabled="type === 'detail' || type === 'audit'"></el-input>
  131. </template>
  132. </el-table-column> -->
  133. <el-table-column label="操作" v-if="type !== 'detail' && type !== 'audit' && type !== 'edit'">
  134. <template slot-scope="scope">
  135. <el-button size="mini" type="danger"
  136. @click="goodsInventoryAddForm.product_list.splice(scope.$index, 1)">删除</el-button>
  137. </template>
  138. </el-table-column>
  139. </el-table>
  140. </el-form-item>
  141. </div>
  142. </el-form>
  143. <div class="footer">
  144. <!-- <el-button v-if="type === 'audit'" type="primary" @click="handlePassGoodsInventoryLoss()">审核通过
  145. </el-button>
  146. <el-button v-if="type === 'audit'" type="danger" @click="dialogVisible = true">审核驳回
  147. </el-button> -->
  148. <el-button v-if="type !== 'edit' && type !== 'audit' && type !== 'detail'" type="primary"
  149. @click="submitGoodsInventoryAddForm">保存
  150. </el-button>
  151. <el-button v-if="type === 'edit'" type="primary" @click="submitcont">审核
  152. </el-button>
  153. <el-button v-if="type === 'edit'" type="primary" @click="submitreject">驳回
  154. </el-button>
  155. <el-button @click="printIng" v-if="type == 'detail'">打印</el-button>
  156. <el-button @click="$router.back()">返回
  157. </el-button>
  158. </div>
  159. <el-dialog title="扫码录入" :visible.sync="scanDialogVisible" width="30%" :close-on-click-modal="false">
  160. <el-form ref="scanGoodsForm" :model="scanGoodsForm" inline label-width="60px">
  161. <el-row>
  162. <el-col :span="18">
  163. <el-form-item label="sku:" prop="bar_code">
  164. <el-input v-model="scanGoodsForm.bar_code" ref="input" @keyup.enter.native="toSearch()" :minlength="0"
  165. :maxlength="100"></el-input>
  166. </el-form-item>
  167. </el-col>
  168. <el-col :span="18">
  169. <el-form-item label="序列号:" prop="sn_code">
  170. <el-input v-model="sn_code" ref="sn_input" @keyup.enter.native="toSnCode()" :minlength="0"
  171. :maxlength="100"></el-input>
  172. </el-form-item>
  173. </el-col>
  174. </el-row>
  175. </el-form>
  176. <span slot="footer" class="dialog-footer">
  177. <!-- <el-button @click="dialogVisible = false">取 消</el-button>
  178. <el-button type="primary" @click="handleRejectGoodsExchange()">确 定</el-button> -->
  179. </span>
  180. </el-dialog>
  181. <el-dialog title="提示" :visible.sync="dialogVisible" width="30%">
  182. <el-form ref="goodsInventoryAddForm" :model="goodsInventoryAddForm" label-width="120px" inline
  183. style="width:900px">
  184. <el-form-item label="驳回原因" prop="reject_reason">
  185. <el-input v-model="goodsInventoryAddForm.reject_reason" type="textarea" :minlength="0"
  186. :maxlength="100"></el-input>
  187. </el-form-item>
  188. </el-form>
  189. <span slot="footer" class="dialog-footer">
  190. <el-button @click="dialogVisible = false">取 消</el-button>
  191. <el-button type="primary" @click="handleRejectGoodsInventoryLoss()">确 定</el-button>
  192. </span>
  193. </el-dialog>
  194. </div>
  195. </template>
  196. <script>
  197. import { mapGetters } from 'vuex'
  198. import { Foundation, RegExp } from '~/ui-utils'
  199. import * as API_GoodsInventoryLossLoss from '@/api/goodsInventoryLoss'
  200. import * as API_GoodsExchange from "@/api/goodsExchange";
  201. import * as API_Setting from '@/api/setting'
  202. import * as API_BasicSetting from '@/api/basicSetting'
  203. import * as API_Erp from '@/api/erp'
  204. import * as API_Auth from '@/api/auth'
  205. export default {
  206. name: 'goodsInventoryAdd',
  207. data() {
  208. const checkPrice = (rule, value, callback) => {
  209. if (!value && value !== 0) {
  210. return callback(new Error('调整金额不能为空'))
  211. } else if (!RegExp.money.test(value)) {
  212. callback(new Error('请输入正整数或者两位小数'))
  213. } else if (parseFloat(value) > 99999999) {
  214. callback(new Error('调整金额设置超过上限值'))
  215. } else {
  216. callback()
  217. }
  218. }
  219. return {
  220. adminList: [],
  221. dialogVisible: false,
  222. warehouseList: [],
  223. deptList: [],
  224. deptListAll: [],
  225. roleSplit: [],
  226. id: '',
  227. type: '',
  228. /** 出库单表单*/
  229. goodsInventoryAddForm: {
  230. product_list: [],
  231. creator_id: ''
  232. },
  233. /** 校验规则 */
  234. goodsInventoryAddFormRule: {
  235. warehouse_id: { required: true, message: '请选择报仓库', trigger: 'change' },
  236. damage_type_value: { required: true, message: '请选择报损类型', trigger: 'change' },
  237. /* report_desc: this.MixinRequired('请填写报损说明'), */
  238. dept_id: { required: true, message: '请选择所属部门', trigger: 'change' },
  239. creator_id: { required: true, message: '请选择制单人', trigger: 'change' }
  240. },
  241. warehouseProduct: null,
  242. scanDialogVisible: false,
  243. sn_code: "",
  244. sku: "",
  245. sn_code_list: [],
  246. index: "",
  247. scanGoodsForm: {},
  248. }
  249. },
  250. computed: {
  251. ...mapGetters(['user'])
  252. },
  253. mounted() {
  254. if (this.$route.name === 'goodsInventoryLossEdit') {
  255. console.log(112);
  256. this.type = 'edit'
  257. } else if (this.$route.name === 'goodsInventoryLossAudit') {
  258. this.type = 'audit'
  259. } else if (this.$route.name === 'goodsInventoryLossReturn') {
  260. this.type = 'return'
  261. } else if (this.$route.name === 'goodsInventoryLossAdd') {
  262. this.type = 'add'
  263. this.goodsInventoryAddForm.creator_id = this.user.uid
  264. this.goodsInventoryAddForm.dept_id = this.user.dept_id
  265. this.GET_WarehouseList({ dept_id: this.user.dept_id })
  266. /* this.$set(this.goodsInventoryAddForm, 'report_time', new Date().getTime()) */
  267. } else if (this.$route.name === 'goodsInventoryLossDetail') {
  268. this.type = 'detail'
  269. }
  270. if (this.$route.params.id) {
  271. this.id = this.$route.params.id
  272. this.GET_goodsInventoryAddDetail()
  273. }
  274. this.GET_DeptList()
  275. this.GET_DictDataInfo()
  276. this.GET_WarehouseList({ dept_id: this.user.dept_id })
  277. this.GET_AdministratorList()
  278. },
  279. methods: {
  280. /* 驳回 */
  281. submitreject() {
  282. this.$refs['goodsInventoryAddForm'].validate(valid => {
  283. if (valid) {
  284. const { id } = this.goodsInventoryAddForm
  285. const params = this.MixinClone(this.goodsInventoryAddForm)
  286. if (params.dept_id) {
  287. params.dept_name = this.deptListAll.find(dept => dept.id === params.dept_id).name
  288. }
  289. if (params.warehouse_id) {
  290. params.warehouse_name = this.warehouseList.find(ware => ware.id === params.warehouse_id).name
  291. }
  292. /* params.report_time = Math.floor(params.report_time / 1000) */
  293. if (params.damage_type_value) {
  294. params.damage_type_key = this.roleSplit.find(ware => ware.value === params.damage_type_value).label
  295. }
  296. if (params.creator_id) {
  297. params.creator = this.adminList.find(admin => admin.id === params.creator_id).real_name
  298. }
  299. params.status = 'CANCEL_HANDLE'
  300. params.product_list = params.product_list.map(item => {
  301. const query = {
  302. report_num: item.report_num,
  303. product_id: item.product_id,
  304. product_stock_id: item.product_stock_id
  305. }
  306. return query
  307. })
  308. API_GoodsInventoryLossLoss.submit(id, params).then(response => {
  309. this.$message.success('驳回成功!')
  310. const { callback } = this.$route.params
  311. if (typeof callback === 'function') callback()
  312. this.$store.dispatch('delCurrentViews', {
  313. view: this.$route,
  314. $router: this.$router
  315. })
  316. this.$router.push({ name: 'goodsInventoryLoss' })
  317. })
  318. }
  319. })
  320. },
  321. // 扫码出库
  322. scanCode() {
  323. this.scanDialogVisible = true;
  324. this.$nextTick(() => {
  325. this.$refs.input.focus();
  326. });
  327. },
  328. /* 出库扫码 */
  329. toSearch() {
  330. API_GoodsExchange.getProduct(
  331. this.goodsInventoryAddForm.warehouse_id,
  332. this.scanGoodsForm.bar_code.replace(/\s+/g, '')
  333. ).then((res) => {
  334. res.sn_code_list = []
  335. this.sku = res.product_vo.sku;
  336. // 查找当前商品是否已存在于列表中
  337. const indexs = this.goodsInventoryAddForm.product_list.findIndex((el) => {
  338. return (
  339. el.goods_vo.id === res.goods_id &&
  340. el.product_id === res.product_id &&
  341. el.product_vo.sku === res.product_vo.sku
  342. );
  343. });
  344. // 如果商品不存在,则添加到列表
  345. if (indexs === -1) {
  346. /* // 检查是否有相同商品在product_list中
  347. const existingProduct = this.goodsInventoryAddForm.product_list.find(el => (
  348. el.goods_vo.id === res.goods_id &&
  349. el.product_id === res.product_id &&
  350. el.product_vo.sku === res.product_vo.sku
  351. ));
  352. if (!existingProduct) {
  353. this.$message.error('订单内没有该商品,请重新录入');
  354. this.$nextTick(() => {
  355. this.$refs.input.focus();
  356. });
  357. return; // 退出函数,不继续执行
  358. } */
  359. this.index = this.goodsInventoryAddForm.product_list.length
  360. this.goodsInventoryAddForm.product_list.push(res);
  361. } else {
  362. this.index = indexs
  363. }
  364. if (res.product_vo.have_sn) {
  365. this.$nextTick(() => {
  366. this.$refs.sn_input.focus();
  367. });
  368. } else {
  369. this.goodsInventoryAddForm.product_list[this.index].report_num += 1
  370. if (this.goodsInventoryAddForm.product_list[this.index].report_num == this.goodsInventoryAddForm.product_list[this.index].num) {
  371. this.scanDialogVisible = false;
  372. }
  373. }
  374. });
  375. },
  376. //扫序列号goodsInventoryAddForm.product_list[this.index].sn_code_list
  377. toSnCode() {
  378. if (this.sku == '') return this.$message.error('请录入正确的sku')
  379. API_GoodsExchange.getSnCode("out", this.sku, this.sn_code.replace(/\s+/g, '')).then((res) => {
  380. this.sn_code = "";
  381. // 假设res是一个对象,我们根据res的某个属性(如sn)来检查重复
  382. let exists = this.goodsInventoryAddForm.product_list[
  383. this.index
  384. ].sn_code_list.find(
  385. (item) => item.sn_code === res.sn_code && item.sku === res.sku
  386. );
  387. if (!exists) {
  388. this.goodsInventoryAddForm.product_list[this.index].sn_code_list.push(
  389. res
  390. );
  391. }
  392. this.goodsInventoryAddForm.product_list[this.index].report_num = this.goodsInventoryAddForm.product_list[this.index].sn_code_list.length
  393. const indexs = this.goodsInventoryAddForm.product_list.findIndex((el) => {
  394. return (
  395. el.goods_id === res.goods_id &&
  396. el.product_id === res.product_id &&
  397. el.product_vo.sku === res.sku
  398. );
  399. });
  400. this.goodsInventoryAddForm.product_list[this.index].id = this.goodsInventoryAddForm.product_list[indexs].id
  401. this.scanGoodsForm.bar_code = "";
  402. /* this.scanDialogVisible = false; */
  403. this.scanGoodsForm.bar_code = "";
  404. this.$nextTick(() => {
  405. this.$refs.input.focus();
  406. });
  407. });
  408. },
  409. /* 确认 */
  410. submitcont() {
  411. this.$refs['goodsInventoryAddForm'].validate(valid => {
  412. if (valid) {
  413. const { id } = this.goodsInventoryAddForm
  414. const params = this.MixinClone(this.goodsInventoryAddForm)
  415. if (params.dept_id) {
  416. params.dept_name = this.deptListAll.find(dept => dept.id === params.dept_id).name
  417. }
  418. if (params.warehouse_id) {
  419. params.warehouse_name = this.warehouseList.find(ware => ware.id === params.warehouse_id).name
  420. }
  421. /* params.report_time = Math.floor(params.report_time / 1000) */
  422. if (params.damage_type_value) {
  423. params.damage_type_key = this.roleSplit.find(ware => ware.value === params.damage_type_value).label
  424. }
  425. if (params.creator_id) {
  426. params.creator = this.adminList.find(admin => admin.id === params.creator_id).real_name
  427. }
  428. params.product_list = params.product_list.map(item => {
  429. const query = {
  430. report_num: item.report_num,
  431. product_id: item.product_id,
  432. product_stock_id: item.product_stock_id
  433. }
  434. return query
  435. })
  436. API_GoodsInventoryLossLoss.submit(id, params).then(response => {
  437. this.$message.success('审核成功!')
  438. const { callback } = this.$route.params
  439. if (typeof callback === 'function') callback()
  440. this.$store.dispatch('delCurrentViews', {
  441. view: this.$route,
  442. $router: this.$router
  443. })
  444. this.$router.push({ name: 'goodsInventoryLoss' })
  445. })
  446. }
  447. })
  448. },
  449. getadminList(value) {
  450. // Access orderTypeList directly from the component's data
  451. const type = this.adminList.find(type => type.id === value);
  452. return type ? type.real_name : '未知类型';
  453. },
  454. getRoleSplit(value) {
  455. // Access orderTypeList directly from the component's data
  456. const type = this.roleSplit.find(type => type.value === value);
  457. return type ? type.label : '未知类型';
  458. },
  459. getWarehouse(value) {
  460. // Access orderTypeList directly from the component's data
  461. const type = this.warehouseList.find(type => type.id === value);
  462. return type ? type.name : '未知类型';
  463. },
  464. // 打印功能
  465. printIng() {
  466. },
  467. /** 修改报单人 */
  468. changeCreator(e) {
  469. this.$forceUpdate()
  470. },
  471. /** 清除已选商品明细 */
  472. cleanGoodsList() {
  473. // 切换部门或仓库需要清除已选对应仓库下的商品数据
  474. this.goodsInventoryAddForm.product_list = []
  475. },
  476. /** 获取人员列表 */
  477. GET_AdministratorList() {
  478. API_Auth.getAdministratorList({
  479. page_no: 1,
  480. page_size: 9999,
  481. user_state: 0
  482. }).then(response => {
  483. this.adminList = response.data
  484. })
  485. },
  486. GET_DictDataInfo() {
  487. API_Setting.getDictDataInfo('es_stock_damage_report').then(response => {
  488. this.roleSplit = response
  489. })
  490. },
  491. /** 审核-通过 */
  492. handlePassGoodsInventoryLoss() {
  493. this.$confirm('确定通过吗?', '提示', { type: 'warning' }).then(() => {
  494. // const ids = this.multipleSelection.map(item => item.id)
  495. API_GoodsInventoryLossLoss.auditGoodsInventoryLoss(this.id, { status: 'PASS' }).then(() => {
  496. this.$message.success('已通过!')
  497. const { callback } = this.$route.params
  498. if (typeof callback === 'function') callback()
  499. this.$store.dispatch('delCurrentViews', {
  500. view: this.$route,
  501. $router: this.$router
  502. })
  503. this.$router.push({ name: 'goodsInventoryLoss' })
  504. })
  505. }).catch(() => { })
  506. },
  507. /** 审核-拒绝 */
  508. handleRejectGoodsInventoryLoss() {
  509. this.$confirm('确定拒绝吗?', '提示', { type: 'warning' }).then(() => {
  510. // const ids = this.multipleSelection.map(item => item.id)
  511. API_GoodsInventoryLossLoss.auditGoodsInventoryLoss(this.id, { status: 'REJECT', reject_reason: this.goodsInventoryAddForm.reject_reason }).then(() => {
  512. this.$message.success('已拒绝!')
  513. const { callback } = this.$route.params
  514. if (typeof callback === 'function') callback()
  515. this.$store.dispatch('delCurrentViews', {
  516. view: this.$route,
  517. $router: this.$router
  518. })
  519. this.$router.push({ name: 'goodsInventoryLoss' })
  520. })
  521. }).catch(() => { })
  522. },
  523. changewarehouseList(e) {
  524. this.$set(this.goodsInventoryAddForm, 'warehouse_id', '')
  525. this.GET_WarehouseList({ dept_id: e })
  526. this.cleanGoodsList()
  527. },
  528. /** 获取仓库 */
  529. GET_WarehouseList(e) {
  530. API_BasicSetting.getWarehouseListAll().then(response => {
  531. this.warehouseList = response
  532. })
  533. },
  534. submitGoodsInventoryAddForm() {
  535. this.$refs['goodsInventoryAddForm'].validate(valid => {
  536. if (valid) {
  537. const { id } = this.goodsInventoryAddForm
  538. const params = this.MixinClone(this.goodsInventoryAddForm)
  539. if (params.dept_id) {
  540. params.dept_name = this.deptListAll.find(dept => dept.id === params.dept_id).name
  541. }
  542. if (params.warehouse_id) {
  543. params.warehouse_name = this.warehouseList.find(ware => ware.id === params.warehouse_id).name
  544. }
  545. /* params.report_time = Math.floor(params.report_time / 1000) */
  546. if (params.damage_type_value) {
  547. params.damage_type_key = this.roleSplit.find(ware => ware.value === params.damage_type_value).label
  548. }
  549. if (params.creator_id) {
  550. params.creator = this.adminList.find(admin => admin.id === params.creator_id).real_name
  551. }
  552. params.product_list = params.product_list.map(item => {
  553. const query = {
  554. report_num: item.report_num,
  555. product_id: item.product_id,
  556. product_stock_id: item.id,
  557. sn_code_list: item.sn_code_list
  558. }
  559. return query
  560. })
  561. if (id) {
  562. API_GoodsInventoryLossLoss.editgoodsInventoryLossAdd(id, params).then(response => {
  563. this.$message.success('修改成功!')
  564. const { callback } = this.$route.params
  565. if (typeof callback === 'function') callback()
  566. this.$store.dispatch('delCurrentViews', {
  567. view: this.$route,
  568. $router: this.$router
  569. })
  570. this.$router.push({ name: 'goodsInventoryLoss' })
  571. })
  572. } else {
  573. API_GoodsInventoryLossLoss.addgoodsInventoryLossAdd(params).then(() => {
  574. this.$message.success('添加成功!')
  575. const { callback } = this.$route.params
  576. if (typeof callback === 'function') callback()
  577. this.$store.dispatch('delCurrentViews', {
  578. view: this.$route,
  579. $router: this.$router
  580. })
  581. this.$router.push({ name: 'goodsInventoryLoss' })
  582. })
  583. }
  584. }
  585. })
  586. },
  587. // 选择出库单
  588. async handleSelectWarehouseEntryBatch() {
  589. if (!this.goodsInventoryAddForm.warehouse_id) {
  590. this.$message.error('请先选择仓库!')
  591. return
  592. }
  593. const goodsData = await this.$EnwarehouseEntryBatch({
  594. goodsApi: `/admin/erp/warehouseOut/getGoodByWarehouse/${this.goodsInventoryAddForm.warehouse_id}`,
  595. warehouseList: this.warehouseList,
  596. selectedIds: this.id ? this.goodsInventoryAddForm.product_list && this.goodsInventoryAddForm.product_list.map(item => item.id) : this.goodsInventoryAddForm.product_list.map(item => item.id),
  597. purchasePlanApiParams: { warehouse_id: this.goodsInventoryAddForm.warehouse_id }
  598. })
  599. this.goodsInventoryAddForm.warehouse_id = goodsData.warehouse_id
  600. this.goodsInventoryAddForm.product_list = goodsData.purchasePlans
  601. /* .map(item => {
  602. const query = {
  603. stock_sn: item.warehouse_id,
  604. product_sn: item.product_sn,
  605. product_name: item.product_name,
  606. specification: item.warehouse_id,
  607. unit: item.product_unit,
  608. stock_num: item.remain_num,
  609. price: item.entry_price,
  610. cost_price: item.product_cost_price,
  611. tax_rate: item.tax_rate,
  612. batch_id: item.id,
  613. goods_id: item.goods_id,
  614. product_id: item.product_id,
  615. batch_sn: item.sn,
  616. category_id: item.category_id,
  617. category_name: item.category_name
  618. }
  619. return query
  620. }) */
  621. },
  622. /** 获取部门 */
  623. GET_DeptList() {
  624. API_Setting.getDeptList().then(response => {
  625. this.deptList = Foundation.buildTree(response, '0')
  626. this.deptListAll = response
  627. })
  628. },
  629. /** 获取详情页面数据 */
  630. GET_goodsInventoryAddDetail() {
  631. API_GoodsInventoryLossLoss.getGoodsInventoryLossInfo(this.id).then(response => {
  632. response.product_list.map(el => {
  633. el.num = el.report_num
  634. /* console.log(this.type); */
  635. /* if (this.type == 'edit') {
  636. el.report_num = 0
  637. } */
  638. })
  639. this.goodsInventoryAddForm = response
  640. /* this.GET_WarehouseList({ dept_id: response.dept_id }) */
  641. /* this.goodsInventoryAddForm.report_time = Math.floor(this.goodsInventoryAddForm.report_time * 1000) */
  642. this.goodsInventoryAddForm.distribution_name = response.staff_name
  643. /*this.goodsInventoryAddForm.product_list = this.goodsInventoryAddForm.product_list.map(el => {
  644. item.product_specification = item.specification
  645. item.product_unit = item.unit
  646. item.remain_num = item.stock_num
  647. el.allow_sn=el.goods_vo.allow_sn
  648. el.bar_code=el.goods_vo.bar_code
  649. el.brand_id=el.goods_vo.brand_id
  650. el.brand_name=el.goods_vo.brand_name
  651. el.category_id=el.goods_vo.category_id
  652. el.category_ids=el.goods_vo.category_ids
  653. el.category_name=el.goods_vo.category_name
  654. el.cost_price=el.goods_vo.cost_price
  655. el.create_time=el.goods_vo.create_time
  656. el.creator=el.goods_vo.creator
  657. el.description=el.goods_vo.description
  658. el.en_name=el.goods_vo.en_name
  659. el.freight_template_id=el.goods_vo.freight_template_id
  660. el.goods_style=el.goods_vo.goods_style
  661. el.goods_unit=el.goods_vo.goods_unit
  662. el.goods_unit=el.goods_vo.goods_unit
  663. el.have_spec=el.goods_vo.have_spec
  664. el.hire_or_sail=el.goods_vo.hire_or_sail
  665. el.image=el.goods_vo.image
  666. el.image_list=el.goods_vo.image_list
  667. el.label_names=el.goods_vo.label_names
  668. el.market_enable=el.goods_vo.market_enable
  669. el.mkt_price=el.goods_vo.mkt_price
  670. el.name=el.goods_vo.name
  671. el.params_list=el.goods_vo.params_list
  672. el.price=el.goods_vo.price
  673. el.sn=el.goods_vo.sn
  674. el.sn_code=el.goods_vo.sn_code
  675. el.sort=el.goods_vo.sort
  676. el.update_time=el.goods_vo.update_time
  677. el.updater=el.goods_vo.updater
  678. el.usable_stock=el.goods_vo.usable_stock
  679. el.video=el.goods_vo.video
  680. return el
  681. })*/
  682. })
  683. }
  684. }
  685. }
  686. </script>
  687. <style type="text/scss" lang="scss" scoped>
  688. /** 底部步骤 */
  689. .footer {
  690. width: 100%;
  691. padding: 10px;
  692. bottom: 0px;
  693. text-align: center;
  694. z-index: 999;
  695. }
  696. .mx {
  697. display: flex;
  698. align-items: center;
  699. width: 100%;
  700. .button {
  701. margin-left: 10px;
  702. }
  703. }
  704. .change-form {
  705. display: flex;
  706. justify-content: flex-start;
  707. align-items: flex-start;
  708. flex-wrap: wrap;
  709. min-width: 900px;
  710. .change-form-item {
  711. width: 30%;
  712. margin: 0 10px 20px 0;
  713. display: flex;
  714. flex-direction: row;
  715. flex-wrap: nowrap;
  716. }
  717. /deep/ {
  718. .el-form-item__content {
  719. flex: 1;
  720. width: 100%;
  721. }
  722. .el-date-editor,
  723. .el-cascader,
  724. .el-select {
  725. width: 100%;
  726. }
  727. }
  728. }
  729. .bg-in-stock {
  730. background-color: #fff;
  731. margin: 10px;
  732. padding: 25px;
  733. }
  734. .goods-info {
  735. display: flex;
  736. .goods-name-box {
  737. text-align: left;
  738. .goods-name {
  739. text-overflow: ellipsis;
  740. display: -webkit-box;
  741. -webkit-line-clamp: 2;
  742. -webkit-box-orient: vertical;
  743. overflow: hidden;
  744. line-height: 16px;
  745. }
  746. .specs {
  747. color: #999999;
  748. }
  749. }
  750. }
  751. /deep/ {
  752. .el-input--suffix .el-input__inner {
  753. padding-right: 10px;
  754. }
  755. .error-input {
  756. .el-input__inner {
  757. border: 1px solid red;
  758. }
  759. }
  760. }
  761. </style>