足力健前端,vue版本

afterSale.vue 14KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. <template>
  2. <div v-loading="loading">
  3. <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="150px" class="order_form">
  4. <el-form-item label="订单编号" prop="F_OrderId" >
  5. <el-input v-model="ruleForm.F_OrderId" disabled />
  6. </el-form-item>
  7. <el-form-item label="售后类型" prop="F_Type" >
  8. <el-select v-model="ruleForm.F_Type" class="form_select" filterable clearable placeholder="请选择售后类型" @change="changeType">
  9. <el-option label="调换" value="1"></el-option>
  10. <el-option label="退货" value="2"></el-option>
  11. <!-- <el-option label="部分退货" value="3"></el-option> -->
  12. <el-option label="对发货" value="4"></el-option>
  13. <el-option label="补发货" value="5"></el-option>
  14. <!-- <el-option label="补差额" value="6"></el-option> -->
  15. <el-option label="错发" value="7"></el-option>
  16. <!-- <el-option label="漏发" value="8"></el-option> -->
  17. </el-select>
  18. </el-form-item>
  19. <el-form-item label="变动金额" prop="F_Money">
  20. <el-input-number v-model="ruleForm.F_Money" controls-position="right" class="form_input_number"></el-input-number>
  21. <!-- <el-input v-model="ruleForm.F_Money" placeholder="-需要退 +用户需补"/> -->
  22. </el-form-item>
  23. <el-form-item label="售后原因" prop="F_ReturnType" >
  24. <el-select v-model="ruleForm.F_ReturnType" class="form_select" filterable clearable placeholder="请选择售后原因">
  25. <el-option v-for="item in afterSaleReasonsList" :key="item.F_ValueId" :label="item.F_Value" :value="item.F_Value"></el-option>
  26. </el-select>
  27. </el-form-item>
  28. <!-- <el-form-item label="售后原因" prop="F_ReturnDes" >
  29. <el-input v-model="ruleForm.F_ReturnDes" placeholder="请输入售后原因" />
  30. </el-form-item> -->
  31. <el-form-item label="退回商品状态" prop="F_ProductStatus" >
  32. <el-input v-model="ruleForm.F_ProductStatus" placeholder="请输入退回商品状态" />
  33. </el-form-item>
  34. <el-form-item label="处理原因" prop="F_Reason" >
  35. <el-input v-model="ruleForm.F_Reason" placeholder="请输入处理原因" />
  36. </el-form-item>
  37. <el-form-item label="客户意愿" prop="F_Aspiration" >
  38. <el-input v-model="ruleForm.F_Aspiration" placeholder="请输入客户意愿" />
  39. </el-form-item>
  40. <el-row>
  41. <el-col :span='8'>
  42. <el-form-item label="商品分类" prop="parentids" >
  43. <el-cascader
  44. v-model="parentids"
  45. :options="commodityTypeLists"
  46. :props="typeDropProps"
  47. placeholder="请选择商品分类"
  48. clearable
  49. filterable
  50. change-on-select
  51. @change="commodityTypeChange"
  52. style="width: 100%;"/>
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span='8'>
  56. <el-form-item label="商品" prop="productName" >
  57. <el-select v-model="commoditySearchData.productName" class="filter-item" value-key="F_ProductId" clearable placeholder="请选择商品" @change="commodityListChange">
  58. <el-option
  59. v-for="item in commodityListLists"
  60. :key="item.F_ProductId"
  61. :label="item.F_ProductName"
  62. :value="item">
  63. </el-option>
  64. </el-select>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span='8'>
  68. <el-form-item label="商品数量" prop="num" >
  69. <el-input-number v-model="commoditySearchData.num" :min="1" label="描述文字"></el-input-number>
  70. </el-form-item>
  71. </el-col>
  72. </el-row>
  73. <el-row>
  74. <el-form-item>
  75. <el-button type="primary" @click="addCommodity">添加商品</el-button>
  76. </el-form-item>
  77. </el-row>
  78. <el-row>
  79. <el-col :span='24'>
  80. <el-form-item label="补发商品">
  81. <el-table :data="commodityTableData" stripe style="width: 100%">
  82. <el-table-column prop="F_ProductName" label="商品名称" align="center" ></el-table-column>
  83. <el-table-column prop="F_Count" label="商品数量" align="center"></el-table-column>
  84. <el-table-column label="操作" align="center">
  85. <template slot-scope="scope">
  86. <el-button type="text" @click="btn_deleteCommodity(scope.row)">删除</el-button>
  87. </template>
  88. </el-table-column>
  89. </el-table>
  90. </el-form-item>
  91. </el-col>
  92. </el-row>
  93. <el-row>
  94. <el-col :span='24'>
  95. <el-form-item label="退回商品">
  96. <el-table :data="oldCommodityTableData" stripe style="width: 100%" @selection-change="handleSelectionChange" ref="oldCommodityTable" >
  97. <el-table-column type="selection" width="55"></el-table-column>
  98. <el-table-column prop="F_ProductName" label="商品名称" align="center" ></el-table-column>
  99. <el-table-column prop="F_Count" label="商品数量" align="center"></el-table-column>
  100. </el-table>
  101. </el-form-item>
  102. </el-col>
  103. </el-row>
  104. <el-form-item label="售后备注" prop="F_Remark">
  105. <el-input :autosize="{ minRows: 4}" v-model="ruleForm.F_Remark" type="textarea" placeholder="请输入售后备注"/>
  106. </el-form-item>
  107. <el-form-item>
  108. <el-button type="primary" @click="submitForm(0)">保存</el-button>
  109. <!-- <el-button type="primary" @click="submitForm(1)">提交</el-button> -->
  110. </el-form-item>
  111. </el-form>
  112. </div>
  113. </template>
  114. <script>
  115. import { getDictionaryValueList } from '@/api/commonAPI'
  116. import { getOrder } from '@/api/orderManagement/orderList'
  117. import { getCommodityType } from '@/api/commodityManagement/commodityType'
  118. import { getCommodityList } from '@/api/commodityManagement/commodityList'
  119. import { addAfterSaleList, getAfterSaleList, getAfterSaleOrderCommodityList } from "@/api/afterSaleManagement/afterSaleList";
  120. export default {
  121. name: "AfterSale",
  122. props: {
  123. rowid: {
  124. type: String,
  125. default: ""
  126. },
  127. collectionAfterSalesReasonType: {
  128. type: String,
  129. default: ""
  130. },
  131. layerid: {
  132. type: String,
  133. default: ""
  134. }
  135. },
  136. data() {
  137. return {
  138. parentids: [],
  139. afterSaleReasonsList: [], //售后原因类型
  140. commodityTypeLists: [], //商品分类下拉数据
  141. // 自定义菜单下拉数据的key值
  142. typeDropProps: {
  143. value: 'id',
  144. label: 'text'
  145. },
  146. commodityListLists: [], // 商品列表
  147. commodityTableData: [], //添加商品
  148. commoditySearchData: { //商品搜索数据
  149. classId: '', // 商品分类id
  150. className: '', // 商品分类名称
  151. productName: '', //商品名称
  152. productId: '', //商品id
  153. num: 1, //商品数量
  154. },
  155. oldCommodityTableData: [], //退回商品列表
  156. oldDetailListSelection: [], // 退回商品选中数据
  157. ruleForm: {
  158. F_OrderId: '', //订单编号
  159. F_DetailList: '', //补发产品列表
  160. F_OldDetailList: '', //退回产品列表
  161. F_Type: '', //合并类型
  162. F_Money: '', //减免金额
  163. F_Remark: '', //销售备注
  164. F_ReturnType: '', //售后原因类型
  165. F_ReturnDes: '', //售后原因
  166. F_ProductStatus: '', //退回商品状态
  167. F_CheckStateSH: '', //0保存 1提交按钮 2不通过
  168. F_Reason: '', //处理原因
  169. F_Aspiration: '', //客户意愿
  170. },
  171. rules: {
  172. order1: [{
  173. required: true,
  174. trigger: 'blur',
  175. message: '请输入订单编号1',
  176. }],
  177. order2: [{
  178. required: true,
  179. trigger: 'blur',
  180. message: '请输入订单编号2',
  181. }],
  182. F_Type: [{
  183. required: true,
  184. trigger: 'change',
  185. message: '请选择售后类型',
  186. }],
  187. F_Money: [{
  188. required: true,
  189. trigger: 'blur',
  190. message: '请输入变动金额',
  191. }],
  192. F_ReturnType: [{
  193. required: true,
  194. trigger: 'change',
  195. message: '请选择售后原因类型',
  196. }],
  197. // F_ReturnDes: [{
  198. // required: true,
  199. // trigger: 'blur',
  200. // message: '请输入售后原因',
  201. // }],
  202. },
  203. loading: false
  204. };
  205. },
  206. created() {
  207. this.getCommodityTypeSelect()
  208. this.getAfterSaleReasons()
  209. Promise.all([
  210. ]).then(() => {
  211. if (this.rowid) {
  212. this.ruleForm.F_OrderId = this.rowid
  213. this.getAfterSaleOrderCommodity(this.rowid)
  214. }
  215. if (this.collectionAfterSalesReasonType) {
  216. this.ruleForm.F_ReturnType = this.collectionAfterSalesReasonType
  217. }
  218. });
  219. },
  220. methods: {
  221. submitForm(state) {
  222. this.$refs.ruleForm.validate(valid => {
  223. if (valid) {
  224. this.loading = true;
  225. this.ruleForm.F_CheckStateSH = state
  226. //添加
  227. addAfterSaleList(this.ruleForm).then(response => {
  228. this.loading = false
  229. if (response.state.toLowerCase() === 'success') {
  230. this.$parent.$layer.close(this.layerid)
  231. this.$parent.getList() // 重新加载父级数据
  232. this.$message.success('恭喜你,添加成功!')
  233. }
  234. }).catch(() => {
  235. this.loading = false
  236. })
  237. return
  238. } else {
  239. this.$message.error("请输入有效的必填项信息!");
  240. return false;
  241. }
  242. });
  243. },
  244. //获取商品分类
  245. getCommodityTypeSelect() {
  246. this.loading = true
  247. return new Promise(resolve => {
  248. const data = {
  249. pageindex: 1, // int 第几页
  250. pagesize: 300, // int 每页几条信息
  251. ParentId: 0,
  252. }
  253. getCommodityType(data).then(response => {
  254. this.loading = false
  255. if (response.state.toLowerCase() === 'success') {
  256. this.commodityTypeLists = response.data
  257. }
  258. })
  259. resolve()
  260. })
  261. },
  262. commodityTypeChange(item) {
  263. this.commoditySearchData.classId = this.parentids[this.parentids.length - 1]
  264. this.getCommodityListSelect()
  265. },
  266. commodityListChange(item) {
  267. this.commoditySearchData.productId = item.F_ProductId
  268. this.commoditySearchData.productName = item.F_ProductName
  269. },
  270. //获取商品
  271. getCommodityListSelect() {
  272. this.loading = true
  273. return new Promise(resolve => {
  274. const params = {
  275. pageindex: 1, // int 第几页,
  276. pagesize: 300, // int 每页几条信息,
  277. ProductId: '',
  278. ClassId: this.commoditySearchData.classId === '' ? 0 : this.commoditySearchData.classId,
  279. ClassName: '',
  280. ProductName: '',
  281. PinyinShort: '',
  282. ProductNumber: '',
  283. ProductShortName: '',
  284. tag: '',
  285. issale: 1,
  286. }
  287. getCommodityList(params).then(response => {
  288. this.loading = false
  289. if (response.state.toLowerCase() === 'success') {
  290. this.commodityListLists = response.data.Rows
  291. }
  292. })
  293. resolve()
  294. })
  295. },
  296. addCommodity() {
  297. if (this.commoditySearchData.productName === ''){
  298. this.$message({
  299. message: '请选择商品!',
  300. type: 'warning'
  301. })
  302. return
  303. }
  304. if (this.commodityTableData.length > 0) {
  305. for (let i=0; i < this.commodityTableData.length; i++ ) {
  306. if (this.commodityTableData[i].F_ProductId === this.commoditySearchData.productId) {
  307. this.commodityTableData[i].F_Count = this.commodityTableData[i].F_Count + this.commoditySearchData.num
  308. return
  309. }
  310. }
  311. }
  312. let data = {
  313. F_ProductId: this.commoditySearchData.productId,
  314. F_ProductName: this.commoditySearchData.productName,
  315. F_Count: this.commoditySearchData.num,
  316. }
  317. this.commodityTableData.push(data)
  318. let idsQuantity = []
  319. for (let i=0; i<this.commodityTableData.length; i++) {
  320. idsQuantity.push(this.commodityTableData[i].F_ProductId + ',' +this.commodityTableData[i].F_Count)
  321. }
  322. this.ruleForm.F_DetailList = idsQuantity.join('|') //补发产品列表
  323. },
  324. //删除商品
  325. btn_deleteCommodity (val) {
  326. let index = this.commodityTableData.indexOf(val)
  327. this.commodityTableData.splice(index, 1)
  328. },
  329. // 售后订单商品列表
  330. getAfterSaleOrderCommodity(rid) {
  331. const params = {
  332. orderid: rid
  333. }
  334. getAfterSaleOrderCommodityList(params).then(response => {
  335. if (response.state.toLowerCase() === 'success') {
  336. const res = response.data
  337. this.oldCommodityTableData = res
  338. this.$nextTick(()=>{
  339. this.oldCommodityTableData.forEach((row,index)=>{
  340. this.$refs.oldCommodityTable.toggleRowSelection(row)
  341. })
  342. },1)
  343. }
  344. })
  345. },
  346. //售后原因类型
  347. getAfterSaleReasons() {
  348. return new Promise(resolve=>{
  349. const params={
  350. isleaf:true,
  351. code:'AfterSaleReasons'
  352. }
  353. getDictionaryValueList(params).then(response=>{
  354. if(response.state.toLowerCase() === 'success'){
  355. this.afterSaleReasonsList = response.data.Rows
  356. }
  357. })
  358. })
  359. },
  360. //选择多个
  361. handleSelectionChange(selection) {
  362. let idsQuantity = []
  363. this.oldDetailListSelection = selection
  364. for (let i=0; i<this.oldDetailListSelection.length; i++) {
  365. idsQuantity.push(this.oldDetailListSelection[i].F_ProductId + ',' + this.oldDetailListSelection[i].F_Count)
  366. }
  367. this.ruleForm.F_OldDetailList = idsQuantity.join('|')
  368. },
  369. // 售后类型改变
  370. changeType(val) {
  371. if(val === "5") {
  372. this.$refs.oldCommodityTable.clearSelection()
  373. } else {
  374. this.oldCommodityTableData.forEach((row,index)=>{
  375. this.$refs.oldCommodityTable.toggleRowSelection(row, true)
  376. })
  377. }
  378. },
  379. }
  380. };
  381. </script>
  382. <style rel="stylesheet/scss" lang="scss">
  383. .order_form .form_select {
  384. width: 100%;
  385. }
  386. .form_input_number {
  387. width: 100%;
  388. }
  389. </style>