EditTradeNameDialog.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <template>
  2. <el-dialog title="修改商品名称" :visible.sync="visible" width="86%" append-to-body>
  3. <u--input v-model="inputForm.tradeName" placeholder="请输入商品名称"></u--input>
  4. <span slot="footer">
  5. <el-button @click="visible = false">取消</el-button>
  6. <el-button type="primary" @click="submit">确定</el-button>
  7. </span>
  8. </el-dialog>
  9. </template>
  10. <script>
  11. import WareHouseService from '@/api/psi/WareHouseService'
  12. export default {
  13. name: 'EditTradeNameDialog',
  14. data() {
  15. return {
  16. visible: false,
  17. inputForm: {
  18. oldTradeName: '',
  19. tradeName: '',
  20. wareHouseType: '',
  21. wareHouseTypeName: ''
  22. }
  23. }
  24. },
  25. wareHouseService: null,
  26. created() {
  27. this.wareHouseService = new WareHouseService()
  28. },
  29. methods: {
  30. open(row) {
  31. this.inputForm = {
  32. oldTradeName: (row && row.tradeName) || '',
  33. tradeName: (row && row.tradeName) || '',
  34. wareHouseType: (row && row.wareHouseType) || '',
  35. wareHouseTypeName: (row && row.wareHouseTypeName) || ''
  36. }
  37. this.visible = true
  38. },
  39. submit() {
  40. if (!this.inputForm.tradeName) {
  41. uni.showToast({
  42. title: '商品名称不能为空',
  43. icon: 'none'
  44. })
  45. return
  46. }
  47. uni.showModal({
  48. title: '提示',
  49. content: `确定将 [${this.inputForm.wareHouseTypeName}] 商品 "${this.inputForm.oldTradeName}" 全部改为 "${this.inputForm.tradeName}" 吗?`,
  50. success: async res => {
  51. if (!res.confirm) {
  52. return
  53. }
  54. await this.wareHouseService.saveTradeName(this.inputForm.oldTradeName, this.inputForm.tradeName, this.inputForm.wareHouseType)
  55. this.visible = false
  56. uni.showToast({
  57. title: '修改成功',
  58. icon: 'success'
  59. })
  60. this.$emit('success')
  61. }
  62. })
  63. }
  64. }
  65. }
  66. </script>