editCopy copy.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. <template>
  2. <div>
  3. <!-- <el-button size="mini" :disabled="data.status !== '新建'" :type="btnType?btnType:'text'" @click="onShow" >编 辑</el-button>-->
  4. <!-- <el-button size="mini" :disabled="data.status !== '新建'" :type="data.status === '新建'?primary:text" @click="onShow" >编 辑</el-button>-->
  5. <el-drawer
  6. title="编辑报价单"
  7. :visible.sync="drawer"
  8. size="92%"
  9. direction="rtl"
  10. :show-close="false"
  11. append-to-body
  12. @close="onClose">
  13. <div class="drawer__panel" style="margin-bottom: 0px">
  14. <el-row style="margin-top: 10px">
  15. <el-form :model="form" :rules="rules" ref="form" size="mini" label-position="right">
  16. <el-col :span="6">
  17. <el-form-item label="报价类型:" label-width="90px" >
  18. <el-input v-model="form.quotedpricetype" autocomplete="off" placeholder="报价类型" disabled></el-input>
  19. </el-form-item>
  20. </el-col>
  21. <el-col :span="6">
  22. <el-form-item label="是否特价:" label-width="90px" >
  23. <el-input v-model="form.specialoffer === 0?'否':'是'" autocomplete="off" placeholder="是否特价" disabled></el-input>
  24. </el-form-item>
  25. </el-col>
  26. <el-col :span="6" v-if="isQuotedPrice">
  27. <el-form-item label="项目名称:" label-width="90px" prop="projectname">
  28. <el-popover
  29. placement="bottom"
  30. width="580"
  31. trigger="click"
  32. v-model="projectShow"
  33. @show="projectList">
  34. <el-table :data="project.projectData">
  35. <el-table-column
  36. label="项目编号"
  37. width="180">
  38. <template slot-scope="scope">
  39. <span style="margin-left: 10px">{{ scope.row.projectnum?scope.row.projectnum:'--' }}</span>
  40. </template>
  41. </el-table-column>
  42. <el-table-column
  43. label="项目名称"
  44. width="180">
  45. <template slot-scope="scope">
  46. <span style="margin-left: 10px">{{ scope.row.projectname?scope.row.projectname:'--' }}</span>
  47. </template>
  48. </el-table-column>
  49. <el-table-column
  50. label="地址"
  51. width="300">
  52. <template slot-scope="scope">
  53. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  54. </template>
  55. </el-table-column>
  56. <el-table-column
  57. fixed="right"
  58. label="操作"
  59. width="60">
  60. <template slot-scope="scope">
  61. <el-button type="text" @click="projectData(scope.row)" @focus="projectShow = true">选择</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <div class="container normal-panel" style="text-align:right">
  66. <el-pagination
  67. background
  68. small
  69. @size-change="handleSizeChangeProject"
  70. @current-change="handleCurrentChangeProject"
  71. :current-page="project.currentPage"
  72. :total="project.total">
  73. </el-pagination>
  74. </div>
  75. <el-input slot="reference" v-model="form.projectname" autocomplete="off" placeholder="请选择项目" @input="selectProject"></el-input>
  76. </el-popover>
  77. </el-form-item>
  78. </el-col>
  79. <el-col :span="6" v-if="isQuotedPrice">
  80. <el-form-item label="项目编号:" label-width="90px" >
  81. <el-input v-model="form.projectnum" autocomplete="off" placeholder="项目编号" disabled></el-input>
  82. </el-form-item>
  83. </el-col>
  84. <el-col :span="6">
  85. <el-form-item label="客户名称:" label-width="90px" prop="enterprisename">
  86. <el-popover
  87. placement="bottom"
  88. width="580"
  89. trigger="click"
  90. v-model="customerShow"
  91. @show="customerList">
  92. <el-table :data="customer.customerData">
  93. <el-table-column
  94. label="客户编号"
  95. width="180">
  96. <template slot-scope="scope">
  97. <span style="margin-left: 10px">{{ scope.row.sa_customersid?scope.row.sa_customersid:'--' }}</span>
  98. </template>
  99. </el-table-column>
  100. <el-table-column
  101. label="客户名称"
  102. width="200">
  103. <template slot-scope="scope">
  104. <span style="margin-left: 10px">{{ scope.row.enterprisename?scope.row.enterprisename:'--'}}</span>
  105. </template>
  106. </el-table-column>
  107. <!-- <el-table-column
  108. label="省市县"
  109. width="230">
  110. <template slot-scope="scope">
  111. <span style="margin-left: 10px">{{ scope.row.province?scope.row.province + '-' + scope.row.city + '-' + scope.row.county:'&#45;&#45;' }}</span>
  112. </template>
  113. </el-table-column>-->
  114. <el-table-column
  115. label="地址"
  116. width="300">
  117. <template slot-scope="scope">
  118. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  119. </template>
  120. </el-table-column>
  121. <el-table-column
  122. fixed="right"
  123. label="操作"
  124. width="60">
  125. <template slot-scope="scope">
  126. <el-button type="text" @click="customerData(scope.row)" @focus="customerShow = true">选择</el-button>
  127. </template>
  128. </el-table-column>
  129. </el-table>
  130. <div class="container normal-panel" style="text-align:right">
  131. <el-pagination
  132. background
  133. small
  134. @size-change="handleSizeChangeCustomer"
  135. @current-change="handleCurrentChangeCustomer"
  136. :current-page="customer.currentPage"
  137. :total="customer.total">
  138. </el-pagination>
  139. </div>
  140. <el-input slot="reference" v-model="form.enterprisename" autocomplete="off" placeholder="请选择客户" @input="selectCustomer"></el-input>
  141. </el-popover>
  142. </el-form-item>
  143. </el-col>
  144. <el-col :span="6">
  145. <el-form-item label="报价日期:" label-width="90px">
  146. <el-date-picker
  147. v-model="form.billdate"
  148. style="width: 100%"
  149. type="date"
  150. value-format="yyyy-MM-dd"
  151. placeholder="选择日期"
  152. :picker-options="pickerOptions">
  153. </el-date-picker>
  154. </el-form-item>
  155. </el-col>
  156. <el-col :span="6">
  157. <el-form-item label="有效期:" label-width="90px" >
  158. <el-date-picker
  159. v-model="date"
  160. style="width: 100%"
  161. type="daterange"
  162. value-format="yyyy-MM-dd"
  163. range-separator="至"
  164. start-placeholder="开始日期"
  165. end-placeholder="结束日期"
  166. :picker-options="pickerOptions">
  167. </el-date-picker>
  168. </el-form-item>
  169. </el-col>
  170. <el-col :span="6">
  171. <el-form-item label="联系人:" label-width="90px" prop="contactsname">
  172. <el-popover
  173. placement="bottom"
  174. width="580"
  175. trigger="click"
  176. v-model="contactsShow"
  177. @show="contactsList">
  178. <el-table :data="contacts.contactsData">
  179. <el-table-column
  180. label="姓名"
  181. width="180">
  182. <template slot-scope="scope">
  183. <span style="margin-left: 10px">{{ scope.row.name?scope.row.name:'--' }}</span>
  184. </template>
  185. </el-table-column>
  186. <el-table-column
  187. label="手机号"
  188. width="180">
  189. <template slot-scope="scope">
  190. <span style="margin-left: 10px">{{ scope.row.phonenumber?scope.row.phonenumber:'--' }}</span>
  191. </template>
  192. </el-table-column>
  193. <el-table-column
  194. label="邮箱"
  195. width="180">
  196. <template slot-scope="scope">
  197. <span style="margin-left: 10px">{{ scope.row.email?scope.row.email:'--' }}</span>
  198. </template>
  199. </el-table-column>
  200. <el-table-column
  201. label="地址"
  202. width="300">
  203. <template slot-scope="scope">
  204. <span style="margin-left: 10px">{{ scope.row.address?scope.row.address:'--' }}</span>
  205. </template>
  206. </el-table-column>
  207. <el-table-column
  208. fixed="right"
  209. label="操作"
  210. width="60">
  211. <template slot-scope="scope">
  212. <el-button type="text" @click="contactsData(scope.row)" @focus="contactsShow = true">选择</el-button>
  213. </template>
  214. </el-table-column>
  215. </el-table>
  216. <div class="container normal-panel" style="text-align:right">
  217. <el-pagination
  218. background
  219. small
  220. @size-change="handleSizeChangeContacts"
  221. @current-change="handleCurrentChangeContacts"
  222. :current-page="contacts.currentPage"
  223. :total="contacts.total">
  224. </el-pagination>
  225. </div>
  226. <el-input slot="reference" v-model="form.contactsname" autocomplete="off" placeholder="请选择联系人" @input="selectContacts"></el-input>
  227. </el-popover>
  228. </el-form-item>
  229. </el-col>
  230. <el-col :span="6">
  231. <el-form-item label="手机号:" label-width="90px" >
  232. <el-input v-model="form.contactsphonenumber" autocomplete="off" placeholder="手机号" disabled></el-input>
  233. </el-form-item>
  234. </el-col>
  235. <!-- <el-col :span="6">
  236. <el-form-item label="总金额:" label-width="90px" >
  237. <el-input v-model="form.totalPrice" autocomplete="off" placeholder="总金额" disabled></el-input>
  238. </el-form-item>
  239. </el-col>-->
  240. </el-form>
  241. </el-row>
  242. </div>
  243. <div >
  244. <el-divider></el-divider>
  245. </div>
  246. <div style="margin:10px 20px 20px 20px">
  247. <quotedPriceProduct :sa_quotedpriceid="form.sa_quotedpriceid" :sa_projectid="form.sa_projectid" :quotedpricetype="form.quotedpricetype" ref="quoterPrice" @checkForm="onSubmit" @productData="productDataChange"></quotedPriceProduct>
  248. </div>
  249. <div class="fixed__btn__panel">
  250. <el-button size="small" @click="onClose" class="normal-btn-width">取 消</el-button>
  251. <el-button size="small" type="warning" @click="getSubmit" class="normal-btn-width">保 存</el-button>
  252. </div>
  253. </el-drawer>
  254. </div>
  255. </template>
  256. <script>
  257. import quotedPriceProduct from '@/SDrpManagement/QuotedPrice/components/edit/quotedPriceProduct'
  258. export default {
  259. name: "edit",
  260. props:['btnType'],
  261. components:{quotedPriceProduct},
  262. data(){
  263. return {
  264. projectShow:false,
  265. customerShow:false,
  266. contactsShow:false,
  267. data:'',
  268. primary:'primary',
  269. text:'',
  270. projectParam:{
  271. "id": 20221020143502,
  272. "content": {
  273. "pageNumber": 1,
  274. "pageSize": 5,
  275. "type":0, // 1:我负责的;2:我参与的;3:我下属负责的;4:我下属参与的
  276. "where": {
  277. "condition": "",
  278. "startdate": "",
  279. "enddate": "",
  280. "status":"",//跟进中、已成交、已失败
  281. "projecttype":"",
  282. "stagename":"",
  283. "tag":""
  284. }
  285. },
  286. },
  287. project:{
  288. projectData:[],
  289. total:0,
  290. currentPage:0,
  291. },
  292. customerParam:{
  293. "id": 20220920083901,
  294. "content": {
  295. "pageNumber": 1,
  296. "pageSize": 5,
  297. "where": {
  298. "condition": "",
  299. "type":4,
  300. "sa_projectid":""
  301. }
  302. }
  303. },
  304. customer:{
  305. customerData:[],
  306. total:0,
  307. currentPage:0,
  308. },
  309. contactsParam:{
  310. "id": "20221022165503",
  311. "version": 1,
  312. "content": {
  313. "sys_enterpriseid":"",
  314. "where": {
  315. "condition": "",
  316. "workaddress": 0//0表示人,1表示地址
  317. }
  318. }
  319. },
  320. contacts:{
  321. contactsData:[],
  322. total:0,
  323. currentPage:0,
  324. },
  325. pickerOptions: {
  326. disabledDate(time) {
  327. return time.getTime() + 3600 * 1000 * 24 < Date.now() ;
  328. },
  329. },
  330. drawer:true,
  331. isQuotedPrice:false,
  332. date:[],
  333. form:{
  334. quotedpricetype:'',
  335. totalPrice:0,
  336. type:'',
  337. projectnum:'',
  338. enterprisename:'',
  339. name:'',
  340. phonenumber:'',
  341. specialOffer:'否',
  342. sa_quotedpriceid:0, //sat_notice_classid<=0时 为新增
  343. sys_enterpriseid: "",
  344. contactsid:8,
  345. sa_projectid: "0",
  346. discountrate: 0,
  347. remarks: "",
  348. invaliddate: "",
  349. projectname: "",
  350. address: "",
  351. billdate:"",
  352. enddate:'',
  353. begdate:''
  354. },
  355. rules:{
  356. projectname:[
  357. { required: true, message: '请选择项目', trigger: 'change'},
  358. ],
  359. enterprisename:[
  360. { required: true, message: '请选择客户', trigger: 'change'},
  361. ],
  362. contactsname:[
  363. { required: true, message: '请选择联系人', trigger: 'change'},
  364. ]
  365. },
  366. }
  367. },
  368. methods:{
  369. onShow(){
  370. console.log('弹窗')
  371. this.drawer = true
  372. /*this.form = this.data*/
  373. this.form = Object.assign({},this.form,this.data)
  374. this.date[0] = this.form.begdate
  375. this.date[1] = this.form.enddate
  376. if (this.form.quotedpricetype === '项目报价'){
  377. this.isQuotedPrice = true
  378. }else {
  379. this.isQuotedPrice = false
  380. }
  381. /*this.$nextTick(()=>{
  382. this.$refs.quoterPrice.productData(this.data.sa_quotedpriceid)
  383. })*/
  384. },
  385. onClose(){
  386. this.drawer = false
  387. this.$emit('onSuccess')
  388. },
  389. onSubmit(){
  390. console.log(this.data,"点击添加商品")
  391. if (this.data.length !== 0){
  392. this.form.begdate = this.date[0]
  393. this.form.enddate = this.date[1]
  394. }else {
  395. this.form.begdate = ''
  396. this.form.enddate = ''
  397. }
  398. console.log(this.form,"表单")
  399. this.$refs.form.validate(async (valid) => {
  400. if (!valid) return false
  401. const res = await this.$api.requested({
  402. "id": 20221020164803,
  403. "version":1,
  404. "content": this.form
  405. })
  406. console.log(res,"报价单id一")
  407. /*this.$refs.quoterPrice.quoterPrice(res.data.sa_quotedpriceid,res.data.quotedpricetype)*/
  408. })
  409. },
  410. getSubmit(){
  411. console.log(this.data)
  412. if (this.date.length === 0){
  413. this.form.begdate = ''
  414. this.form.enddate = ''
  415. }else {
  416. this.form.begdate = this.date[0]
  417. this.form.enddate = this.date[1]
  418. }
  419. console.log(this.form,"表单")
  420. this.$refs.form.validate(async (valid) => {
  421. if (!valid) return false
  422. const res = await this.$api.requested({
  423. "id": 20221020164803,
  424. "version":1,
  425. "content": this.form
  426. })
  427. this.tool.showMessage(res,() => {
  428. this.drawer = false
  429. this.changeData(this.productObj)
  430. })
  431. })
  432. },
  433. /*修改后的产品数据*/
  434. productDataChange(val){
  435. console.log(val,"修改后的产品数据")
  436. let obj = val.map(e=>{
  437. return {
  438. sa_quotedprice_itemsid:e.sa_quotedprice_itemsid,
  439. itemid:e.itemid,
  440. oldprice:e.marketprice,
  441. price:e.price,
  442. discountrate:(e.discountrate/100).toFixed(4),
  443. qty:e.qty
  444. }
  445. })
  446. this.productObj = obj
  447. },
  448. async changeData(obj){
  449. console.log(this.productObj,"数据")
  450. const res = await this.$api.requested({
  451. "id": 20221021095403,
  452. "content": {
  453. "sa_quotedpriceid":this.form.sa_quotedpriceid, //sat_notice_classid<=0时 为新增
  454. "items":obj
  455. }
  456. })
  457. console.log(res)
  458. this.$emit('onSuccess')
  459. },
  460. /*刷新总金额*/
  461. queryTotalPrice(val){
  462. console.log("总金额",val)
  463. this.form.totalPrice = val
  464. console.log(this.form)
  465. },
  466. async projectList(){
  467. const res = await this.$api.requested(this.projectParam)
  468. console.log(res)
  469. this.project.projectData = res.data
  470. this.project.total = res.total
  471. this.project.currentPage = res.pageNumber
  472. },
  473. async selectProject(){
  474. console.log(this.form.projectname)
  475. this.projectShow = true
  476. this.projectParam.content.where.condition = this.form.projectname
  477. this.projectList()
  478. },
  479. async customerList(){
  480. if (this.form.quotedpricetype === '客户报价'){
  481. this.customerParam.content.where.sa_projectid = 0
  482. this.customerParam.content.where.type = 2
  483. }else {
  484. this.customerParam.content.where.type = 4
  485. this.customerParam.content.where.sa_projectid = this.form.sa_projectid
  486. }
  487. const res = await this.$api.requested(this.customerParam)
  488. this.customer.customerData = res.data
  489. this.customer.total = res.total
  490. this.customer.currentPage = res.pageNumber
  491. },
  492. selectCustomer(){
  493. this.customerParam.content.where.condition = this.form.enterprisename
  494. this.customerList()
  495. },
  496. async contactsList(){
  497. this.contactsParam.content.sys_enterpriseid = this.form.sys_enterpriseid
  498. const res = await this.$api.requested(this.contactsParam)
  499. this.contacts.contactsData = res.data
  500. this.contacts.total = res.total
  501. this.contacts.currentPage = res.pageNumber
  502. },
  503. selectContacts(){
  504. this.contactsShow = true
  505. this.contactsParam.content.where.condition = this.form.name
  506. this.contactsList()
  507. },
  508. /*项目选择信息*/
  509. projectData(val){
  510. this.form.sa_projectid = val.sa_projectid
  511. this.form.projectname = val.projectname
  512. this.form.projectnum = val.projectnum
  513. this.form.sys_enterpriseid = ''
  514. this.form.enterprisename = ''
  515. this.form.contactsid = ''
  516. this.form.contactsname = ''
  517. this.form.contactsphonenumber = ''
  518. },
  519. /*客户选择信息*/
  520. customerData(val){
  521. this.form.sys_enterpriseid = val.sys_enterpriseid
  522. this.form.enterprisename = val.enterprisename
  523. this.form.contactsid = ''
  524. this.form.contactsname = ''
  525. this.form.contactsphonenumber = ''
  526. },
  527. /*联系人选择信息*/
  528. contactsData(val){
  529. this.form.contactsid = val.contactsid
  530. this.form.contactsname = val.name
  531. this.form.contactsphonenumber = val.phonenumber
  532. },
  533. /*项目翻页*/
  534. handleSizeChangeProject(val) {
  535. // console.log(`每页 ${val} 条`);
  536. this.projectParam.content.pageSize = val
  537. this.projectList()
  538. },
  539. handleCurrentChangeProject(val) {
  540. // console.log(`当前页: ${val}`);
  541. this.projectParam.content.pageNumber = val
  542. this.projectList()
  543. },
  544. /*客户翻页*/
  545. handleSizeChangeCustomer(val) {
  546. // console.log(`每页 ${val} 条`);
  547. this.projectParam.content.pageSize = val
  548. this.customerList()
  549. },
  550. handleCurrentChangeCustomer(val) {
  551. // console.log(`当前页: ${val}`);
  552. this.projectParam.content.pageNumber = val
  553. this.customerList()
  554. },
  555. /*联系人翻页*/
  556. handleSizeChangeContacts(val) {
  557. // console.log(`每页 ${val} 条`);
  558. this.projectParam.content.pageSize = val
  559. this.contactsList()
  560. },
  561. handleCurrentChangeContacts(val) {
  562. // console.log(`当前页: ${val}`);
  563. this.projectParam.content.pageNumber = val
  564. this.contactsList()
  565. },
  566. },
  567. mounted() {
  568. this.onShow()
  569. },
  570. created() {
  571. this.data = this.$route.query.data
  572. /*this.drawer = true*/
  573. console.log(this.data,"获取项目报价")
  574. console.log(this.$route.query.data,"获取项目报价1111")
  575. }
  576. }
  577. </script>
  578. <style scoped>
  579. </style>