add.vue 9.7 KB

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