移动端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

287 lines
11 KiB

  1. <template>
  2. <div class="home_wrapper">
  3. <!-- 头部开始 -->
  4. <van-nav-bar
  5. title="发布商品"
  6. fixed
  7. placeholder
  8. left-arrow
  9. @click-left="onClickLeft"
  10. />
  11. <!-- 头部结束 -->
  12. <!-- 内容开始 -->
  13. <van-form @submit="submitForm" ref="formData" show-error :show-error-message="false">
  14. <div class="main">
  15. <van-field label="产品名称" required :rules="[{ required: true }]" v-model="supplyDemand.supplyDemandName" input-align="right" placeholder="请输入产品名称" />
  16. <!-- <van-field label="产品类型" v-model="supplyDemand.productType" input-align="right" placeholder="请输入产品类型" />-->
  17. <van-field
  18. readonly
  19. clickable
  20. required
  21. :rules="[{ required: true , message:'请选择产品类型'}]"
  22. v-model="productType"
  23. label="产品类型"
  24. placeholder="请选择产品类型"
  25. @click="showProductType = true"
  26. input-align="right"
  27. right-icon="arrow-down"
  28. label-width="auto"
  29. />
  30. <van-popup v-model="showProductType" round position="bottom">
  31. <!-- v-model="cascaderValue"-->
  32. <van-cascader
  33. title="请选择产品类型"
  34. :options="productList"
  35. @close="showProductType = false"
  36. @finish="onConfirmProductType"
  37. :field-names="fieldNames"
  38. />
  39. </van-popup>
  40. <!-- <van-field label="二级分类" v-model="supplyDemand.supplyDemandType" input-align="right" placeholder="请输入二级分类" />-->
  41. <van-field label="产品规格" v-model="supplyDemand.specification" input-align="right" placeholder="请输入产品规格" />
  42. <!-- <van-field label="所属主体" v-model="supplyDemand.bodyType" input-align="right" placeholder="请输入所属主体" />-->
  43. <!-- <van-field-->
  44. <!-- readonly-->
  45. <!-- clickable-->
  46. <!-- required-->
  47. <!-- :rules="[{ required: true , message:'请选择所属主体'}]"-->
  48. <!-- v-model="bodyType"-->
  49. <!-- label="所属主体"-->
  50. <!-- placeholder="请选择所属主体"-->
  51. <!-- @click="showBodyType = true"-->
  52. <!-- input-align="right"-->
  53. <!-- right-icon="arrow-down"-->
  54. <!-- label-width="auto"-->
  55. <!-- />-->
  56. <!-- <van-popup v-model="showBodyType" position="bottom">-->
  57. <!-- <van-picker-->
  58. <!-- show-toolbar-->
  59. <!-- :columns="projectTypeOptions"-->
  60. <!-- @confirm="onConfirmProjectType"-->
  61. <!-- @cancel="showBodyType = false"-->
  62. <!-- />-->
  63. <!-- </van-popup>-->
  64. <van-field label="所属主体" required :rules="[{ required: true }]" v-model="supplyDemand.entityName" input-align="right" placeholder="请输入所属主体" />
  65. <van-field label="单价" required :rules="[{ required: true }]" v-model="supplyDemand.unitPrice" type="number" input-align="right" placeholder="请输入单价" />
  66. <van-field label="数量" v-model="supplyDemand.number" type="digit" input-align="right" placeholder="请输入数量" />
  67. <van-field label="单位" required :rules="[{ required: true }]" v-model="supplyDemand.unit" input-align="right" placeholder="请输入单位" />
  68. <van-field label="联系电话" required :rules="[{ required: true }]" v-model="supplyDemand.supplyDemandTal" type="digit" input-align="right" placeholder="请输入联系电话" />
  69. <van-field label="联系人" required :rules="[{ required: true }]" v-model="supplyDemand.linker" input-align="right" placeholder="请输入联系人" />
  70. <van-field
  71. readonly
  72. clickable
  73. required
  74. :rules="[{ required: true , message:'请选择服务区域'}]"
  75. v-model="supplyDemand.serviceDeptName"
  76. label="服务区域"
  77. placeholder="请选择服务区域"
  78. @click="showDeptId = true"
  79. input-align="right"
  80. right-icon="arrow-down"
  81. label-width="auto"
  82. />
  83. <van-popup v-model="showDeptId" position="bottom" get-container="body">
  84. <van-cascader
  85. v-model="villageValue"
  86. title="请选择"
  87. :options="deptOptions"
  88. @close="showDeptId = false"
  89. @finish="onConfirmDept"
  90. active-color="#1989fa"
  91. :field-names="hcAreaInfoFieldName"
  92. />
  93. </van-popup>
  94. <van-field label="地址" v-model="supplyDemand.address" input-align="right" placeholder="请输入地址" />
  95. <van-field label="简介" required :rules="[{ required: true }]" v-model="supplyDemand.introduction" type="textarea" autosize input-align="right" placeholder="请输入简介" />
  96. <van-field label="详情" v-model="supplyDemand.particulars" type="textarea" autosize input-align="right" placeholder="请输入详情" />
  97. <van-field label="图片" :border="false" input-align="right" readonly />
  98. <div style="padding: 0 4% 2vh;">
  99. <van-uploader v-model="supplyDemand.supplyMasterMapList" :after-read="afterReadEvidenceForm" :before-delete="deleteFileEvidenceForm" />
  100. </div>
  101. </div>
  102. <div class="main">
  103. <baidu-map :center="center" panBy="[50,50]" :zoom="zoom" :scroll-wheel-zoom="true" :pinch-to-zoom="true" map-type="BMAP_NORMAL_MAP" style="height:25vh" >
  104. <!-- 必须给容器指高度,不然地图将显示在一个高度为0的容器中,看不到 -->
  105. <bm-marker :position="center" :dragging="true" animation="BMAP_ANIMATION_BOUNCE" :icon="{url: '../../../../static/images/lawEnforcement/new/address.gif', size: {width: 50, height: 50}}"></bm-marker>
  106. </baidu-map>
  107. </div>
  108. <div class="main_btn">
  109. <p @click="publishStatus = '3',$refs.formData.submit()">发布</p>
  110. <p @click="publishStatus = '2',$refs.formData.submit()">存稿</p>
  111. </div>
  112. </van-form>
  113. <!-- 内容结束 -->
  114. </div>
  115. </template>
  116. <script>
  117. import Cookies from "js-cookie";
  118. import {commonUpload, productTypes, supplyDemandAdd, treeselect} from "@/api/agriculturalTrusteeship";
  119. export default {
  120. name: "agriculturalTrusteeshipSocializationRelease",
  121. data() {
  122. return {
  123. activeKey: 0,
  124. active: 0,
  125. loading: false,
  126. finished: false,
  127. showProductType: false,
  128. showBodyType: false,
  129. center: { lng: 122.089726, lat: 37.540728 }, //经纬度
  130. zoom: 15, //地图展示级别
  131. showDialog:false,
  132. supplyDemand:{},
  133. productType:'',
  134. bodyType:'',
  135. projectTypeOptions:[],
  136. productList:[],
  137. productList1:[],
  138. demandTypeOptions:[],
  139. productTypeOptions:[],
  140. supplyMasterMapArr:[],
  141. bodyTypeOptions:[],
  142. fieldNames : {
  143. text: 'dictName',
  144. value: 'id',
  145. children: 'children',
  146. },
  147. publishStatus:'',
  148. deptOptions:[],
  149. deptName:'张村',
  150. showDeptId:false,
  151. villageValue : '',
  152. hcAreaInfoFieldName: {
  153. text: "label",
  154. value: "value",
  155. children: "children",
  156. },
  157. };
  158. },
  159. created() {
  160. let query = {
  161. parentId : '',
  162. tree : true
  163. }
  164. let query1 = {
  165. tree : true
  166. }
  167. productTypes(query).then(response => {
  168. this.productList = response.data;
  169. });
  170. productTypes(query1).then(response => {
  171. this.productList1 = response.data;
  172. });
  173. this.getDicts("newBusinessEntity_statistics_project").then(response => {
  174. for (var i = 0; i < response.data.length; i++) {
  175. this.projectTypeOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
  176. }
  177. this.bodyTypeOptions = response.data;
  178. });
  179. this.getDicts("publish_status").then(response => {
  180. for (var i = 0; i < response.data.length; i++) {
  181. this.projectTypeOptions.push({text: response.data[i].dictLabel, value: response.data[i].dictValue});
  182. }
  183. this.bodyTypeOptions = response.data;
  184. });
  185. treeselect().then(res=>{
  186. if (res.code == 200) {
  187. this.deptOptions = res.data;
  188. }
  189. })
  190. },
  191. methods: {
  192. onConfirmProductType({ selectedOptions }){
  193. this.supplyDemand.productType = selectedOptions[selectedOptions.length-1].id;
  194. this.productType = selectedOptions.map((option) => option.dictName).join('/');
  195. this.showProductType = false;
  196. },
  197. onConfirmProjectType(data){
  198. this.supplyDemand.bodyType = data.value;
  199. this.bodyType = data.text;
  200. this.showBodyType = false;
  201. },
  202. afterReadEvidenceForm(file){
  203. let params1 = new FormData();
  204. params1.append("file", file.file);
  205. commonUpload(params1).then((r1) => {
  206. // this.tEnforceSamplingGoodsList[index].attachement.push(r1.fileName);
  207. console.log(r1)
  208. this.supplyMasterMapArr.push(r1.fileName)
  209. })
  210. },
  211. deleteFileEvidenceForm(file,detail) {
  212. this.supplyMasterMapArr.splice(detail.index,1);
  213. this.supplyDemand.supplyMasterMapList.splice(detail.index,1);
  214. },
  215. submitForm(publishStatus){
  216. this.supplyDemand.supplyMasterMap = this.supplyMasterMapArr.join(',')
  217. this.supplyDemand.supplyDemandType = '1';
  218. this.supplyDemand.publishStatus = this.publishStatus;
  219. supplyDemandAdd(this.supplyDemand).then((res) => {
  220. if(res.code=="200"){
  221. if (this.publishStatus == '3'){
  222. this.$notify({ type: 'success', message: '发布成功' });
  223. }else{
  224. this.$notify({ type: 'success', message: '存稿成功' });
  225. }
  226. setTimeout(function(){
  227. history.back(-1);
  228. },2000)
  229. }
  230. })
  231. },
  232. //选择案件属地
  233. onConfirmDept({ selectedOptions }){
  234. this.supplyDemand.serviceDeptId = selectedOptions[selectedOptions.length-1].value;
  235. this.supplyDemand.serviceDeptName = selectedOptions[selectedOptions.length-1].label;
  236. this.showDeptId = false
  237. },
  238. },
  239. }
  240. </script>
  241. <style scoped lang="scss">
  242. .home_wrapper{
  243. background: #F6F6F6;
  244. min-height: 100vh;
  245. }
  246. .main{
  247. width: 92%;
  248. margin: 0 auto;
  249. margin-top: 2vh;
  250. border-radius: 10PX;
  251. overflow: hidden;
  252. background-color: #FFF;
  253. }
  254. .main_btn{
  255. display: flex;
  256. justify-content: space-around;
  257. padding: 4vh 0;
  258. p{
  259. font-size: .4rem;
  260. width: 35%;
  261. text-align: center;
  262. padding: 10PX 0;
  263. border-radius: 5rem;
  264. box-shadow: 0px 3PX 6PX 0px rgba(0,0,0,0.16);
  265. &:nth-child(1){
  266. background: #334281;
  267. color: #ffffff;
  268. }
  269. &:nth-child(2){
  270. background: #D1D5E4;
  271. color: #334281;
  272. }
  273. }
  274. }
  275. </style>