detail.vue 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  1. <template>
  2. <div class="s-page">
  3. <el-page-header @back="goBack" :content="title"></el-page-header>
  4. <el-divider></el-divider>
  5. <div slot="moreSearch" v-if="formType != 0">
  6. <el-radio-group v-model="tabIndex" size="small" @change="">
  7. <el-radio-button :label="1">基础资料</el-radio-button>
  8. <el-radio-button :label="2">修改记录</el-radio-button>
  9. </el-radio-group>
  10. <br><br>
  11. </div>
  12. <template v-if="tabIndex == 1">
  13. <el-card class="box-card">
  14. <div style="margin-bottom: 20px;font-weight: bold;">项目信息</div>
  15. <div class="mymain-container">
  16. <el-form ref="formData" :rules="rules" :model="formData" label-width="110px" size="small" label-position="left">
  17. <el-row :gutter="20" justify="start">
  18. <el-col :span="12">
  19. <el-form-item label="所属商户" :required="true" >
  20. <el-input type="text" :value="companyName" disabled></el-input>
  21. </el-form-item>
  22. </el-col>
  23. <el-col :span="12">
  24. <el-form-item label="项目名称" prop="projectName" :required="true" >
  25. <el-input type="text" v-model="formData.projectName" :disabled="formType==2" placeholder="请输入"></el-input>
  26. </el-form-item>
  27. </el-col>
  28. <el-col :span="12">
  29. <el-form-item label="负责人" prop="manger" :required="true" >
  30. <el-input type="text" v-model="formData.manger" :disabled="formType==2" placeholder="请输入"></el-input>
  31. </el-form-item>
  32. </el-col>
  33. <el-col :span="12">
  34. <el-form-item label="联系电话" prop="mobile" :required="true">
  35. <el-input type="text" v-model="formData.mobile" :disabled="formType==2" placeholder="请输入"></el-input>
  36. </el-form-item>
  37. </el-col>
  38. <el-col :span="12">
  39. <el-form-item label="维保时间" prop="dateList" :required="true">
  40. <el-date-picker
  41. :disabled="formType==2"
  42. v-model="formData.dateList"
  43. @change="selectDate"
  44. value-format="yyyy-MM-dd"
  45. type="daterange"
  46. range-separator="至"
  47. start-placeholder="开始日期"
  48. end-placeholder="结束日期">
  49. </el-date-picker>
  50. </el-form-item>
  51. </el-col>
  52. <el-col :span="12">
  53. <el-form-item label="工单类型" prop="orderSmallTypeText" :required="true">
  54. <el-checkbox-group v-model="formData.checkTypeList">
  55. <el-checkbox v-for="(item,index) in orderTypeList" :disabled="formType==2" :key="index" :label="item.id">{{item.orderSmallTypeText}}</el-checkbox>
  56. </el-checkbox-group>
  57. </el-form-item>
  58. </el-col>
  59. <el-col :span="12">
  60. <el-form-item label="包含全部费用" prop="isAllFee" :required="true">
  61. <el-radio-group v-model="formData.isAllFee">
  62. <el-radio :disabled="formType==2" label="YES">是</el-radio>
  63. <el-radio :disabled="formType==2" label="NO">否</el-radio>
  64. </el-radio-group>
  65. </el-form-item>
  66. </el-col>
  67. <el-col :span="12">
  68. <el-form-item v-if="formData.isAllFee == 'NO'" label="费用支付方式" prop="feePayMethod" :required="true">
  69. <el-radio-group v-model="formData.feePayMethod">
  70. <el-radio :disabled="formType==2" label="EXAMINE">审批后结算</el-radio>
  71. <el-radio :disabled="formType==2" label="SITE">现场支付</el-radio>
  72. </el-radio-group>
  73. </el-form-item>
  74. </el-col>
  75. <el-col :span="24">
  76. <el-form-item label="项目地址" prop="province" :required="true">
  77. <el-row>
  78. <el-col :span="5" style="margin-right: 12px;">
  79. <el-input type="text" v-model="formData.province" disabled placeholder="请选择省"></el-input>
  80. </el-col>
  81. <el-col :span="5" style="margin-right: 12px;">
  82. <el-input type="text" v-model="formData.city" disabled placeholder="请选择市"></el-input>
  83. </el-col>
  84. <el-col :span="5" style="margin-right: 12px;">
  85. <el-input type="text" v-model="formData.area" disabled placeholder="请选择区"></el-input>
  86. </el-col>
  87. <el-col :span="8">
  88. <el-input type="text" v-model="formData.street" disabled placeholder="请选择街道"></el-input>
  89. </el-col>
  90. </el-row>
  91. </el-form-item>
  92. </el-col>
  93. <el-col :span="24">
  94. <el-form-item label="" prop="address" :required="true">
  95. <el-row :gutter="20">
  96. <el-col :span="22">
  97. <el-input type="text" v-model="formData.address" :disabled="formType==2" placeholder="详细地址"></el-input>
  98. </el-col>
  99. <el-col :span="2">
  100. <geographicalPosi :disabled="formType==2" :formData="this.formData" @selectPosi="selectAddress"/>
  101. </el-col>
  102. </el-row>
  103. </el-form-item>
  104. </el-col>
  105. <el-col :span="24">
  106. <el-form-item label="项目说明">
  107. <el-input type="textarea" :rows="4" :disabled="formType==2" v-model="formData.remark" placeholder="请输入"></el-input>
  108. </el-form-item>
  109. </el-col>
  110. </el-row>
  111. </el-form>
  112. </div>
  113. </el-card>
  114. <br/>
  115. <el-card class="box-card">
  116. <el-tabs v-model="typeIndex" @change="changeType">
  117. <el-tab-pane label="项目设备" name="1"></el-tab-pane>
  118. <el-tab-pane label="项目人员" name="2"></el-tab-pane>
  119. <el-tab-pane label="服务网点" name="3"></el-tab-pane>
  120. </el-tabs>
  121. <el-button size="small" v-if="formType!=2" type="primary" @click="add()">新增</el-button>
  122. <div class="table">
  123. <!-- 项目设备 -->
  124. <el-form ref="formData1" :model="formData1">
  125. <el-table v-if="typeIndex == 1" :data="formData1.productList" element-loading-text="Loading" border fit highlight-current-row stripe>
  126. <el-table-column label="品牌" align="center">
  127. <template slot-scope="scope">
  128. <el-form-item :prop="'productList.' + scope.$index + '.brand'" :rules="[{ required: true, message: `请选择品牌`, trigger: 'change' }]">
  129. <el-select v-model="scope.row.brand" @change="(e)=>{
  130. scope.row.brandId = e.id
  131. scope.row.brandName = e.brandName
  132. }" value-key="id" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  133. <el-option
  134. v-for="item in brandList"
  135. :key="item.id"
  136. :label="item.brandName"
  137. :value="item">
  138. </el-option>
  139. </el-select>
  140. </el-form-item>
  141. </template>
  142. </el-table-column>
  143. <el-table-column label="产品大类" align="center">
  144. <template slot-scope="scope">
  145. <el-form-item :prop="'productList.' + scope.$index + '.main'" :rules="[{ required: true, message: `请选择产品大类`, trigger: 'change' }]">
  146. <el-select v-model="scope.row.main" value-key="categoryId" @change="(e)=>{
  147. scope.row.mainId = e.categoryId
  148. scope.row.mainName = e.name
  149. if(e.categoryId == 0){
  150. scope.row.small = {categoryId: '0', name: '不限'}
  151. scope.row.smallName = '不限'
  152. scope.row.smallId = '0'
  153. }else{
  154. scope.row.small = null
  155. scope.row.smallName = ''
  156. scope.row.smallId = ''
  157. }
  158. scope.row.smallList = e.children?e.children:[]
  159. }" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  160. <el-option
  161. v-for="item in mainList"
  162. :key="item.categoryId"
  163. :label="item.name"
  164. :value="item">
  165. </el-option>
  166. </el-select>
  167. </el-form-item>
  168. </template>
  169. </el-table-column>
  170. <el-table-column label="产品小类" align="center">
  171. <template slot-scope="scope">
  172. <el-form-item :prop="'productList.' + scope.$index + '.small'" :rules="[{ required: true, message: `请选择产品小类`, trigger: 'change' }]">
  173. <el-select v-model="scope.row.small" @focus="()=>{
  174. if(!scope.row.main){return this.$message.warning('请先选择产品大类!');}
  175. }" @change="(e)=>{
  176. scope.row.smallName = e.name
  177. scope.row.smallId = e.categoryId
  178. scope.row.smallImg = e.imgUrl
  179. }" :disabled="isEdit != scope.$index || formType == 2" value-key="categoryId" placeholder="请选择" style="width: 100%;">
  180. <el-option
  181. v-for="item in scope.row.smallList"
  182. :key="item.categoryId"
  183. :label="item.name"
  184. :value="item">
  185. </el-option>
  186. </el-select>
  187. </el-form-item>
  188. </template>
  189. </el-table-column>
  190. <el-table-column prop="" align="center" label="系列名称">
  191. <template slot-scope="scope">
  192. <el-form-item>
  193. <el-input type="text" v-model="scope.row.seriesName" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  194. </el-form-item>
  195. </template>
  196. </el-table-column>
  197. <el-table-column prop="" align="center" label="机型名称">
  198. <template slot-scope="scope">
  199. <el-form-item>
  200. <el-input type="text" v-model="scope.row.productName" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  201. </el-form-item>
  202. </template>
  203. </el-table-column>
  204. <el-table-column align="center" label="设备套数">
  205. <template slot-scope="scope">
  206. <el-form-item :prop="'productList.' + scope.$index + '.num'" :rules="[{ required: true, message: `请输入设备套数`, trigger: 'blur' }]">
  207. <el-input type="number" v-model="scope.row.num" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  208. </el-form-item>
  209. </template>
  210. </el-table-column>
  211. <el-table-column prop="" align="center" label="内机数量" >
  212. <template slot-scope="scope">
  213. <el-form-item>
  214. <el-input type="number" v-model="scope.row.inNum" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  215. </el-form-item>
  216. </template>
  217. </el-table-column>
  218. <el-table-column prop="" align="center" label="外机数量">
  219. <template slot-scope="scope">
  220. <el-form-item>
  221. <el-input type="number" v-model="scope.row.outNum" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  222. </el-form-item>
  223. </template>
  224. </el-table-column>
  225. <el-table-column label="操作" align="right" width="140">
  226. <template slot-scope="scope" v-if="formType != 2">
  227. <el-button size="mini" type="primary" v-if="scope.$index != isEdit" @click="isEdit = scope.$index">编辑</el-button>
  228. <el-button size="mini" type="danger" @click="del(scope.$index)">删除</el-button>
  229. </template>
  230. </el-table-column>
  231. </el-table>
  232. </el-form>
  233. <!-- 项目人员 -->
  234. <el-form v-if="typeIndex == 2" ref="formData2" :model="formData2" label-width="0" size="small" label-position="left">
  235. <el-table :data="formData2.byList" element-loading-text="Loading" border fit highlight-current-row stripe>
  236. <el-table-column align="center" label="姓名">
  237. <template slot-scope="scope">
  238. <el-form-item :prop="'byList.' + scope.$index + '.name'" :rules="[{ required: true, message: `请输入姓名`, trigger: 'blur' }]">
  239. <el-input type="text" v-model="scope.row.name" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  240. </el-form-item>
  241. </template>
  242. </el-table-column>
  243. <el-table-column align="center" label="联系电话" >
  244. <template slot-scope="scope">
  245. <el-form-item :prop="'byList.' + scope.$index + '.mobile'"
  246. :rules="[{ required: true, message: `请输入联系电话`, trigger: 'blur' },{ pattern:/^((0\d{2,3}-\d{7,8})|(1[3456789]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }]">
  247. <el-input type="number" v-model="scope.row.mobile" :disabled="isEdit != scope.$index || formType == 2" placeholder="请输入"></el-input>
  248. </el-form-item>
  249. </template>
  250. </el-table-column>
  251. <el-table-column label="费用审批">
  252. <template slot-scope="scope">
  253. <el-form-item :prop="'byList.' + scope.$index + '.feeExamine'" :rules="[{ required: true, message: `请选择费用审批`, trigger: 'change' }]">
  254. <el-select v-model="scope.row.feeExamine" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  255. <el-option
  256. v-for="item in [{id: 'YES',name: '是'},{id: 'NO',name: '否'}]"
  257. :key="item.id"
  258. :label="item.name"
  259. :value="item.id">
  260. </el-option>
  261. </el-select>
  262. </el-form-item>
  263. </template>
  264. </el-table-column>
  265. </el-table>
  266. </el-form>
  267. <!-- 服务网点 -->
  268. <el-form v-if="typeIndex == 3" ref="formData3" :model="formData3" label-width="0" size="small" label-position="left">
  269. <el-table :data="formData3.websitData" element-loading-text="Loading" border fit highlight-current-row stripe>
  270. <el-table-column align="center" label="网点名称">
  271. <template slot-scope="scope">
  272. <el-form-item :prop="'websitData.' + scope.$index + '.websit'" :rules="[{ required: true, message: `请选择网点名称`, trigger: 'change' }]" :required="true">
  273. <el-select v-model="scope.row.websit" @change="(e)=>{
  274. scope.row.websitId = e.websitId
  275. scope.row.websitName = e.name
  276. scope.row.linkName = e.linkName
  277. scope.row.mobile = e.websitPhone
  278. scope.row.address = e.address
  279. }" value-key="websitId" :disabled="isEdit != scope.$index || formType == 2" placeholder="请选择" style="width: 100%;">
  280. <el-option
  281. v-for="item in websitList"
  282. :key="item.websitId"
  283. :label="item.name"
  284. :value="item">
  285. </el-option>
  286. </el-select>
  287. </el-form-item>
  288. </template>
  289. </el-table-column>
  290. <el-table-column prop="" align="center" label="联系人">
  291. <template slot-scope="scope">
  292. <el-form-item>
  293. <el-input type="text" v-model="scope.row.linkName" disabled placeholder="请输入"></el-input>
  294. </el-form-item>
  295. </template>
  296. </el-table-column>
  297. <el-table-column prop="" align="center" label="移动电话" >
  298. <template slot-scope="scope">
  299. <el-form-item>
  300. <el-input type="number" v-model="scope.row.mobile" disabled placeholder="请输入"></el-input>
  301. </el-form-item>
  302. </template>
  303. </el-table-column>
  304. <el-table-column prop="" align="center" label="地址" >
  305. <template slot-scope="scope">
  306. <el-form-item>
  307. <el-input type="text" v-model="scope.row.address" disabled placeholder="请输入"></el-input>
  308. </el-form-item>
  309. </template>
  310. </el-table-column>
  311. </el-table>
  312. </el-form>
  313. </div>
  314. </el-card>
  315. <div class="page-footer">
  316. <div class="footer">
  317. <el-button v-if="formType != 2" size="small" type="primary" @click="confirm()">保存</el-button>
  318. <el-button size="small" type="info" @click="goBack">返回</el-button>
  319. </div>
  320. </div>
  321. </template>
  322. <template v-else>
  323. <el-card class="box-card">
  324. <div slot="header" class="clearfix">
  325. <span>修改记录</span>
  326. </div>
  327. <div class="table">
  328. <el-table :data="historyList" element-loading-text="Loading" border fit highlight-current-row stripe>
  329. <el-table-column prop="typeText" align="center" label="操作类型" ></el-table-column>
  330. <el-table-column prop="content" align="left" label="操作内容"></el-table-column>
  331. <el-table-column prop="createBy" align="center" label="操作人"></el-table-column>
  332. <el-table-column prop="createTime" align="center" label="操作时间"></el-table-column>
  333. </el-table>
  334. </div>
  335. </el-card>
  336. </template>
  337. </div>
  338. </template>
  339. <script>
  340. import { getWebsit } from "@/api/customerManagement";
  341. import { lbsAmapRegion } from '@/api/common.js'
  342. import geographicalPosi from '@/components/geographicalPosi/index.vue'
  343. import { getMainList } from "@/api/workOrder/settlementStandardInstall";
  344. import { getBrand } from '@/api/goods'
  345. import { getDetail, save } from "@/api/engineeringMaintenance/basicData";
  346. import request from '@/utils/request'
  347. export default {
  348. components: {geographicalPosi},
  349. props: ['id','title','formType'],
  350. data() {
  351. return {
  352. tabIndex: 1,
  353. typeIndex: '1',
  354. orderTypeList: [],
  355. websitList: [],
  356. brandList: [],
  357. historyList: [],
  358. provinceList: [],
  359. cityList: [],
  360. areaList: [],
  361. streetList: [],
  362. mainList: [],
  363. formData: {
  364. dateList: [],
  365. checkTypeList: [],
  366. projectName: '',
  367. manger: '',
  368. mobile: '',
  369. startTime: '',
  370. endTime: '',
  371. orderSmallTypeText: '安装',
  372. isAllFee: 'YES',
  373. feePayMethod: 'EXAMINE',
  374. province: '',
  375. provinceId: '',
  376. city: '',
  377. cityId: '',
  378. area: '',
  379. areaId: '',
  380. street: '',
  381. streetId: '',
  382. address: '',
  383. lat: '',
  384. lng: '',
  385. remark: ''
  386. },
  387. formData1: {
  388. productList: [],
  389. },
  390. formData2: {
  391. byList: [],
  392. },
  393. formData3: {
  394. websitData: [],
  395. },
  396. isEdit: 0,
  397. companyName: JSON.parse(localStorage.getItem('greemall_user')).companyName,
  398. rules: {
  399. projectName: [
  400. { required: true, message: '请输入项目名称', trigger: 'blur' },
  401. ],
  402. manger: [
  403. { required: true, message: '请输入负责人名称', trigger: 'blur' },
  404. ],
  405. mobile: [
  406. { required: true, message: `请输入联系电话`, trigger: 'blur' },
  407. { required: true, message: `请输入联系电话`, trigger: 'change' },
  408. { pattern:/^((0\d{2,3}-\d{7,8})|(1[34578]\d{9}))$/, message: '电话号码格式不正确', trigger: 'blur' }
  409. ],
  410. dateList: [
  411. { required: true, message: '请选择维保时间', trigger: 'change' }
  412. ],
  413. checkTypeList: [
  414. { required: true, message: '请选择工单类型', trigger: 'change' }
  415. ],
  416. address: [
  417. { required: true, message: '请选择详细地址', trigger: 'change' }
  418. ],
  419. },
  420. rules1: {},
  421. rules2: {},
  422. rules3: {},
  423. };
  424. },
  425. computed: {
  426. filterChildren(){
  427. return function(id){
  428. let data = []
  429. this.mainList.forEach(item=>{
  430. if(item.categoryId == id){
  431. data = item.children?item.children:[]
  432. }
  433. })
  434. return data
  435. }
  436. }
  437. },
  438. created() {
  439. if(this.id){
  440. this.getDetail()
  441. }
  442. this.initData()
  443. },
  444. methods: {
  445. // 返回
  446. goBack() {
  447. this.$emit('back');
  448. },
  449. async getDetail(){
  450. const that = this
  451. this.formData.checkTypeList = []
  452. getDetail({id: this.id}).then( async res => {
  453. Object.assign(this.formData, res.data, {
  454. websit: {websitId: res.data.websitId,name: res.data.websitName},
  455. })
  456. this.historyList = res.data.operatorLogList
  457. this.formData.dateList = [res.data.startTime,res.data.endTime]
  458. for(var item of res.data.productList){
  459. item.smallList = await this.filterChildren(item.mainId)
  460. item.brand = {id: item.brandId,brandName: item.brandName}
  461. item.main = {categoryId: item.mainId,name: item.mainName}
  462. item.small = {categoryId: item.smallId,name: item.smallName}
  463. }
  464. res.data.websitList.map(item=>{
  465. item.websit = {websitId: item.websitId,name: item.websitName}
  466. })
  467. res.data.typeList.forEach(item=>{
  468. this.formData.checkTypeList.push(item.id)
  469. })
  470. this.formData2.byList = res.data.byList
  471. this.formData1.productList = res.data.productList
  472. this.formData3.websitData = res.data.websitList
  473. console.log(this.formData.checkTypeList,'123123123')
  474. })
  475. },
  476. initData(){
  477. this.getOrderType()
  478. this.getBrandList()
  479. this.getWebsit()
  480. this.getMainList()
  481. this.getinitlbslist()
  482. },
  483. getOrderType(){
  484. request({
  485. url: `/order/smalltype/list`,
  486. method: 'post',
  487. data: {
  488. pageNum: 1,
  489. pageSize: -1,
  490. params: [{param: 'a.is_rp_project_repair',compare: '=', value: 'YES'}]
  491. }
  492. }).then(res => {
  493. this.orderTypeList = res.data.records
  494. })
  495. },
  496. getBrandList(){
  497. getBrand().then(res => {
  498. this.brandList = [...[{id: '0',brandName: '不限'}],...res.data]
  499. })
  500. },
  501. getMainList(){
  502. getMainList({type: 2}).then(res => {
  503. this.mainList = [...[{categoryId: '0',name: '不限',children: [{categoryId: '0',name: '不限'}]}],...res.data]
  504. })
  505. },
  506. getinitlbslist() {
  507. // 初始化请求省市区街道下拉选项数据
  508. lbsAmapRegion({ pid: 0 }).then(res => {
  509. this.provinceList = res.data
  510. // 创建工单时获取ip地址定位赋值
  511. if (!this.id && this.$IpAdd.province) {
  512. var item = this.provinceList.find(item => item.name === this.$IpAdd.province)
  513. if (item) {
  514. this.formData.provinceId = item.id
  515. this.formData.province = item.name
  516. }
  517. }
  518. if (this.formData.provinceId) {
  519. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  520. this.cityList = res.data
  521. // 创建工单时获取ip地址定位赋值
  522. if (!this.id && this.$IpAdd.city) {
  523. var item2 = this.cityList.find(item => item.name === this.$IpAdd.city)
  524. if (item2) {
  525. this.formData.cityId = item2.id
  526. this.formData.city = item2.name
  527. }
  528. }
  529. if (this.formData.cityId) {
  530. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  531. this.areaList = res.data
  532. })
  533. }
  534. if (this.formData.areaId) {
  535. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  536. this.streetList = res.data
  537. })
  538. }
  539. })
  540. }
  541. })
  542. },
  543. selectAddress(data){
  544. this.formData.lng = data.center[0]
  545. this.formData.lat = data.center[1]
  546. // 获取定位的省市区街道
  547. var { province, city, district, township } = data.data.addressComponent
  548. // 获取选中省名称id
  549. var { id, name } = this.provinceList.find(item => item.name === province)
  550. this.formData.provinceId = id
  551. this.formData.province = name
  552. // 请求市选项
  553. lbsAmapRegion({ pid: this.formData.provinceId }).then(res => {
  554. // 赋值市选项
  555. this.cityList = res.data
  556. // 获取选中市名称id
  557. var { id, name } = res.data.find(item => item.name === city)
  558. this.formData.cityId = id
  559. this.formData.city = name
  560. // 请求区选项
  561. lbsAmapRegion({ pid: this.formData.cityId }).then(res => {
  562. // 赋值区选项
  563. this.areaList = res.data
  564. // 获取选中区名称id
  565. var { id, name } = res.data.find(item => item.name === district)
  566. this.formData.areaId = id
  567. this.formData.area = name
  568. // 请求街道选项
  569. lbsAmapRegion({ pid: this.formData.areaId }).then(res => {
  570. // 赋值街道选项
  571. this.streetList = res.data
  572. // 获取选中街道名称id
  573. var { id, name } = res.data.find(item => item.name === township)
  574. this.formData.streetId = id
  575. this.formData.street = name
  576. // 赋值GPS详细地址
  577. this.formData.address = data.name
  578. })
  579. })
  580. })
  581. },
  582. selectDate(e){
  583. this.formData.startTime = e[0] + ' 00:00:00'
  584. this.formData.endTime = e[1] + ' 23:59:59'
  585. },
  586. getWebsit(){
  587. getWebsit({type: 'C'}).then(res => {
  588. this.websitList = res.data
  589. })
  590. },
  591. getCategory(websitId){
  592. getCategory({websitId}).then(res => {
  593. this.mainList = res.data
  594. })
  595. },
  596. changeType(){
  597. this.isEdit = 0
  598. },
  599. preserveRuleForm(name) {
  600. console.log('this.$refs.'+name)
  601. const that = this
  602. let ruleForm = new Promise(function (resolve, reject) {
  603. that.$refs[name].validate((valid) => {
  604. if (valid) {
  605. resolve(true);
  606. } else {
  607. resolve(false);
  608. }
  609. });
  610. })
  611. return ruleForm
  612. },
  613. add(){
  614. if(!this.preserveRuleForm('formData' + this.typeIndex)){return false}
  615. let name = this.typeIndex == 1?'productList':this.typeIndex == 2?'byList':'websitData'
  616. if(this['formData' + this.typeIndex][name].length != 0){this.isEdit += 1}
  617. if(this.typeIndex == 1){
  618. this['formData' + this.typeIndex][name].push({
  619. brand: null,
  620. brandId: '',
  621. brandName: '',
  622. inNum: '',
  623. main: null,
  624. mainId: '',
  625. mainName: '',
  626. num: '',
  627. outNum: '',
  628. productName: '',
  629. seriesName: '',
  630. small: null,
  631. smallId: '',
  632. smallName: '',
  633. smallImg: ''
  634. })
  635. }else if(this.typeIndex == 2){
  636. this['formData' + this.typeIndex][name].push({
  637. name: '',
  638. mobile: '',
  639. feeExamine: ''
  640. })
  641. }else{
  642. this['formData' + this.typeIndex][name].push({
  643. websit: null,
  644. websitId: '',
  645. websitName: '',
  646. linkName: '',
  647. mobile: '',
  648. address: ''
  649. })
  650. }
  651. },
  652. del(index){
  653. let name = this.typeIndex == 1?'productList':this.typeIndex == 3?'byList':'websitData'
  654. this['formData' + this.typeIndex][name].splice(index,1)
  655. },
  656. confirm(){
  657. const that = this
  658. this.$refs.formData.validate((valid, invalidFields, errLabels) => {
  659. if (valid) {
  660. if(that.formData1.productList.length == 0){
  661. that.typeIndex = 1
  662. return that.$message.error('请添加项目设备信息');
  663. }
  664. if(that.formData2.byList.length == 0){
  665. that.typeIndex = 2
  666. return that.$message.error('请添加项目人员信息');
  667. }
  668. if(that.formData3.websitData.length == 0){
  669. that.typeIndex = 3
  670. return that.$message.error('请添加服务网点信息');
  671. }
  672. if(!that.preserveRuleForm('formData1')){
  673. return that.typeIndex = 1
  674. }
  675. if(!that.preserveRuleForm('formData2')){
  676. return that.typeIndex = 2
  677. }
  678. if(!that.preserveRuleForm('formData3')){
  679. return that.typeIndex = 3
  680. }
  681. this.save()
  682. }
  683. })
  684. },
  685. save(){
  686. let data = this.orderTypeList.filter((it) => {
  687. const index = this.formData.checkTypeList.findIndex((item) => item === it.id)
  688. return index !== -1
  689. })
  690. const that = this
  691. let params = {
  692. ...this.formData,
  693. byList: this.formData2.byList,
  694. productList: this.formData1.productList,
  695. websitList: this.formData3.websitData,
  696. typeList: data
  697. }
  698. save(params).then(res => {
  699. that.$message.success('保存成功!')
  700. setTimeout(()=>{
  701. that.goBack()
  702. },1500)
  703. })
  704. }
  705. }
  706. };
  707. </script>
  708. <style scoped="scoped" lang="scss">
  709. .s-page {
  710. padding: 20px;
  711. background-color: #ffffff;
  712. }
  713. .page-footer {
  714. height: 70px;
  715. }
  716. .footer {
  717. position: fixed;
  718. bottom: 0;
  719. left: 0;
  720. z-index: 1;
  721. width: 100%;
  722. background: #fff;
  723. padding: 15px 40px;
  724. box-sizing: border-box;
  725. transition: all 0.28s;
  726. text-align: right;
  727. box-shadow: 0 2px 5px 0 rgb(0 0 0 / 50%), 0 2px 5px 0 rgb(0 0 0 / 10%);
  728. &.hideSidebar {
  729. margin-left: 54px;
  730. width: calc(100vw - 54px);
  731. }
  732. &.openSidebar {
  733. margin-left: 210px;
  734. width: calc(100vw - 210px);
  735. }
  736. .tips {
  737. font-size: 12px;
  738. color: red;
  739. margin-top: 10px;
  740. }
  741. }
  742. </style>