add.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div id="addAddress">
  3. <el-card style="height: calc(100vh - 15vh);position: relative;overflow: scroll;">
  4. <span>基本信息</span>
  5. <el-form :model="basicForm" :rules="basicRules" ref="basic" label-width="auto">
  6. <el-row :gutter="10">
  7. <el-col :span="1.5">
  8. <el-form-item label="收货仓库编码">
  9. <el-input
  10. v-model="basicForm.code"
  11. size="mini"
  12. disabled
  13. clearable
  14. style="width: 200px"
  15. />
  16. </el-form-item>
  17. </el-col>
  18. <el-col :span="1.5">
  19. <el-form-item label="收货仓库名称">
  20. <el-input
  21. v-model="basicForm.name"
  22. size="mini"
  23. disabled
  24. clearable
  25. style="width: 200px"
  26. />
  27. </el-form-item>
  28. </el-col>
  29. <el-col :span="1.5">
  30. <el-form-item label="仓库档案名称">
  31. <el-select size="mini" v-model="basicForm.warehouse" :disabled="sonDisable" @focus="chooseRefer('WAREHOUSE_PARAM', true, '仓库档案名称')" style="width: 200px">
  32. <el-option v-for="item in houseOptions" :key="item.id" :label="item.name" :value="item.id" />
  33. </el-select>
  34. </el-form-item>
  35. </el-col>
  36. <el-col :span="1.5">
  37. <el-form-item label="仓库属性">
  38. <el-select :disabled="sonDisable" v-model="basicForm.warehouseProperty" size="mini" style="width: 200px">
  39. <el-option v-for="dict in dict.type.sys_warehouse_attribute" :key="dict.value" :label="dict.label" :value="dict.value">
  40. </el-option>
  41. </el-select>
  42. </el-form-item>
  43. </el-col>
  44. <el-col :span="1.5">
  45. <el-form-item label="地址信息">
  46. <el-input
  47. v-model="basicForm.address"
  48. size="mini"
  49. :disabled="sonDisable"
  50. clearable
  51. style="width: 200px"
  52. />
  53. </el-form-item>
  54. </el-col>
  55. <el-col :span="1.5">
  56. <el-form-item label="联系人">
  57. <el-select size="mini" v-model="basicForm.contacts" :disabled="sonDisable" @focus="chooseRefer('CONTACTS_PARAM', true, '联系人')" style="width: 200px">
  58. <el-option v-for="item in contactsOptions" :key="item.id" :label="item.name" :value="item.code" />
  59. </el-select>
  60. </el-form-item>
  61. </el-col>
  62. <el-col :span="1.5">
  63. <el-form-item label="联系人电话">
  64. <el-input
  65. v-model="basicForm.contactsPhone"
  66. size="mini"
  67. :disabled="sonDisable"
  68. clearable
  69. style="width: 200px"
  70. />
  71. </el-form-item>
  72. </el-col>
  73. <el-col :span="1.5">
  74. <el-form-item label="物料分类">
  75. <el-select
  76. v-model="basicForm.materialClassify"
  77. size="mini"
  78. :disabled="sonDisable"
  79. clearable
  80. @focus="chooseTreeRefer('MATERIALCLASSIFY_PARAM', false, '物料分类')"
  81. style="width: 200px"
  82. >
  83. <el-option v-for="item in classOptions" :key="item.id" :label="item.name" :value="item.id" />
  84. </el-select>
  85. </el-form-item>
  86. </el-col>
  87. <el-col :span="1.5">
  88. <el-form-item label="启用">
  89. <el-select disabled v-model="basicForm.status" size="mini" style="width: 200px">
  90. <el-option
  91. v-for="item in options"
  92. :key="item.value"
  93. :label="item.label"
  94. :value="item.value">
  95. </el-option>
  96. </el-select>
  97. </el-form-item>
  98. </el-col>
  99. <el-col :span="1.5">
  100. <el-form-item label="同步状态">
  101. <el-select disabled v-model="basicForm.sendStatus" size="mini" style="width: 200px">
  102. <el-option
  103. v-for="item in options2"
  104. :key="item.value"
  105. :label="item.label"
  106. :value="item.value">
  107. </el-option>
  108. </el-select>
  109. </el-form-item>
  110. </el-col>
  111. <el-col :span="1.5">
  112. <el-form-item label="备注">
  113. <el-input
  114. v-model="basicForm.remark"
  115. size="mini"
  116. :disabled="sonDisable"
  117. clearable
  118. style="width: 200px"
  119. />
  120. </el-form-item>
  121. </el-col>
  122. </el-row>
  123. </el-form>
  124. <div class="btn_group">
  125. <el-button type="primary" size="mini" @click="editPage" v-if="sonPageStu == 'check'">编辑</el-button>
  126. <el-button type="primary" size="mini" plain @click="save" v-if="sonPageStu == 'add' || sonPageStu == 'edit'">保存</el-button>
  127. <!-- <el-col :span="1.5" style="margin: 0 10px;">
  128. <el-button type="primary" size="mini" plain @click="submit" v-if="sonPageStu == 'edit'">提交</el-button>
  129. </el-col> -->
  130. <el-button size="mini" plain @click="back">返回</el-button>
  131. </div>
  132. </el-card>
  133. <Refers ref="refer" @doSubmit="selectionsToInput" :single="true"/>
  134. <TreeRefers ref="tree" @doSubmit="selectionsToInput2" :single="true"/>
  135. </div>
  136. </template>
  137. <script>
  138. import Refers from '@/components/Refers/refers.vue'
  139. import TreeRefers from '@/components/Refers/sigleTreeRefer.vue'
  140. import {addAddress, getAddressDetail, editAddress} from '@/api/purchase/deliveryAddress.js'
  141. // 用于回显参照框数据
  142. import { getRefer } from '@/api/purchase/basic.js'
  143. export default {
  144. name: 'addAddress',
  145. dicts: ['sys_warehouse_attribute'],
  146. props: ['pageStu','row', 'disable'],
  147. components: {
  148. Refers,
  149. TreeRefers
  150. },
  151. model: {
  152. prop: 'isList',
  153. event: 'jugislist'
  154. },
  155. data() {
  156. return {
  157. // 不能直接改变props传来的值
  158. sonPageStu: this.pageStu,
  159. sonDisable: this.disable,
  160. basicForm: {
  161. code: '',
  162. name: '',
  163. warehouse: '',
  164. warehouseName: '',
  165. warehouseProperty: '',
  166. address: '',
  167. contacts: '',
  168. contactsName: '',
  169. contactsPhone: '',
  170. materialClassify: '',
  171. materialClassifyName: '',
  172. status: 'Y',
  173. sendStatus: 'N',
  174. remark: '',
  175. },
  176. referCondition: {
  177. type: '',
  178. isPage: true,
  179. title: ''
  180. },
  181. options: [{
  182. value: 'Y', label: '启用',
  183. }, {
  184. value: 'N', label: '停用'
  185. }],
  186. options2: [{
  187. value: 'Y', label: '已同步',
  188. }, {
  189. value: 'N', label: '未同步'
  190. }],
  191. houseOptions: [],
  192. contactsOptions: [],
  193. classOptions: [],
  194. basicRules: {}
  195. }
  196. },
  197. mounted() {
  198. if(this.pageStu == 'check') {
  199. console.log('数据', this.row)
  200. this.getDetails(this.row)
  201. } else if(this.pageStu == 'edit') {
  202. this.getDetails(this.row)
  203. }
  204. },
  205. methods: {
  206. save() {
  207. if(this.sonPageStu == 'add') {
  208. this.$modal.loading("保存中...");
  209. addAddress(this.basicForm).then(res => {
  210. if (res.code === 200) {
  211. this.$modal.notifySuccess("保存成功");
  212. this.$modal.closeLoading();
  213. this.back()
  214. }
  215. }).catch(err => {
  216. this.$modal.closeLoading();
  217. })
  218. } else if (this.sonPageStu == 'edit') {
  219. this.$modal.loading("保存中...");
  220. editAddress(this.basicForm).then(res => {
  221. if (res.code === 200) {
  222. this.$modal.notifySuccess("编辑成功");
  223. this.$modal.closeLoading();
  224. this.back()
  225. }
  226. }).catch(err => {
  227. this.$modal.closeLoading();
  228. })
  229. }
  230. },
  231. editPage() {
  232. this.sonPageStu = 'edit'
  233. this.sonDisable = false
  234. },
  235. submit() {},
  236. back() {
  237. this.$emit('jugislist', true)
  238. // let queryParams = {
  239. // pageNum: 1,
  240. // pageSize: 10
  241. // }
  242. this.$emit('refresh')
  243. },
  244. // 如果需要回显则调用详情接口
  245. getDetails(row) {
  246. getAddressDetail(row.id).then(res => {
  247. if (res.code === 200) {
  248. this.basicForm = res.data
  249. if (this.basicForm.warehouse) { this.reBackRefer('WAREHOUSE_PARAM', this.basicForm.warehouse) }
  250. if (this.basicForm.contacts) { this.reBackRefer('CONTACTS_PARAM', this.basicForm.contacts) }
  251. if (this.basicForm.materialClassify) { this.reBackRefer('MATERIALCLASSIFY_PARAM', this.basicForm.materialClassify) }
  252. }
  253. })
  254. },
  255. chooseRefer(type, isPage, title) {
  256. this.referCondition.type = type
  257. this.referCondition.isPage = isPage
  258. this.referCondition.title = title
  259. this.$refs.refer.init(this.referCondition)
  260. },
  261. selectionsToInput(selection) {
  262. if (this.referCondition.type == 'WAREHOUSE_PARAM') {
  263. this.houseOptions = selection
  264. this.basicForm.warehouseName = selection[0].name
  265. this.basicForm.name = selection[0].name
  266. this.basicForm.warehouse = selection[0].id
  267. }
  268. if (this.referCondition.type == 'CONTACTS_PARAM') {
  269. this.contactsOptions = selection
  270. this.basicForm.contactsName = selection[0].name
  271. this.basicForm.contacts = selection[0].code
  272. }
  273. },
  274. chooseTreeRefer(type, isPage, title) {
  275. this.referCondition.type = type
  276. this.referCondition.isPage = isPage
  277. this.referCondition.title = title
  278. this.$refs.tree.init(this.referCondition)
  279. },
  280. selectionsToInput2(selection) {
  281. this.classOptions.push(selection)
  282. this.basicForm.materialClassify = selection.id
  283. this.basicForm.materialClassifyName = selection.name
  284. },
  285. // 回显参照框 加title解决判断重复提交问题
  286. reBackRefer(type, id, title) {
  287. getRefer({ type: type, id: id, title: title }).then(res => {
  288. if (type == 'WAREHOUSE_PARAM') {
  289. this.houseOptions = res.rows
  290. }
  291. if (type == 'CONTACTS_PARAM') {
  292. this.contactsOptions = res.rows
  293. }
  294. if (type == 'MATERIALCLASSIFY_PARAM') {
  295. this.classOptions = res.rows
  296. }
  297. })
  298. },
  299. }
  300. }
  301. </script>
  302. <style lang="scss" scoped>
  303. .btn_group {
  304. // width: 100%;
  305. // margin: 20px 0;
  306. display: flex;
  307. justify-content: space-between;
  308. position: absolute;
  309. top: 10px;right: 20px;
  310. }
  311. </style>