form.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. <template>
  2. <zj-page-container>
  3. <zj-page-fill class="neibuview">
  4. <zj-form-container ref="formRef" :form-data="formData" :form-rules="formRules">
  5. <zj-form-module title="商品详情" :form-data="formData" :form-items="formItems" label-width="80px">
  6. </zj-form-module>
  7. <zj-form-module v-if="formData.id && ~['SALE'].indexOf(cpdata.status)" title="出售信息" class="my-module" :form-data="formData.order" :form-items="formItems2"
  8. label-width="0px"/>
  9. <zj-form-module title="查看留言" class="my-module" :form-data="formData.order" :form-items="formItems3"
  10. label-width="0px"/>
  11. </zj-form-container>
  12. </zj-page-fill>
  13. <div style="box-sizing: border-box; padding: 10px; text-align: right;">
  14. <el-button v-if="!disabled" type="primary" size="small" @click="handleSubmit">保存</el-button>
  15. <el-button v-if="formData.id && ~['SALE'].indexOf(formData.status)" type="primary" size="small"
  16. @click="copyGoods">克隆商品</el-button>
  17. <el-button v-if="formData.id && ~['ON'].indexOf(formData.status)" type="primary" size="small"
  18. @click="setStatus('OFF')">下架</el-button>
  19. <el-button v-if="formData.id && ~['ON'].indexOf(formData.status)" type="primary" size="small"
  20. @click="zhuanxiaoshou">转销售</el-button>
  21. <el-button v-if="formData.id && ~['OFF'].indexOf(formData.status)" type="primary" size="small"
  22. @click="setStatus('ON')">重新上架</el-button>
  23. <el-button size="small" @click="handleClose">取消</el-button>
  24. </div>
  25. </zj-page-container>
  26. </template>
  27. <script>
  28. import ImageUpload from '@/components/file-upload'
  29. import { esGoodsDetail, esGoodsCopy, esGoodsBatchUpdateStatus, esGoodsReply, esGoodsUpdate } from '@/api/commodityManagement'
  30. import { getClassifyList } from '@/api/goods'
  31. export default {
  32. components: { ImageUpload },
  33. props: {
  34. detailId: {
  35. type: String,
  36. default: ''
  37. }
  38. },
  39. data() {
  40. return {
  41. classifyList: [],
  42. formData: {
  43. "brand": "",
  44. "categoryId": "",
  45. "categoryName": "",
  46. "companyWechatId": "",
  47. "companyWechatName": "",
  48. "del": true,
  49. "goodsName": "",
  50. "goodsNote": "",
  51. "imgList": [],
  52. "isTop": true,
  53. "likeCount": 0,
  54. "makeDate": "",
  55. "mark": "",
  56. "markId": "",
  57. "messageList": [],
  58. "operateRecordList": [],
  59. "power": "",
  60. "price": 0,
  61. "qty": 0,
  62. "queryCount": 0,
  63. "remark": "",
  64. "sort": 0,
  65. "status": "",
  66. "topTime": "",
  67. "userId": ""
  68. },
  69. formRules: {},
  70. publishStatus: [
  71. { label: '下架', value: "OFF" },
  72. { label: '上架', value: "ON" },
  73. { label: '已卖出', value: "SALE" },
  74. ],
  75. cpdata:{},
  76. }
  77. },
  78. computed: {
  79. disabled(){
  80. return ~['ON', 'OFF'].indexOf(this.cpdata?.status) ? false : true
  81. },
  82. formItems() {
  83. return [
  84. {
  85. name: 'el-select',
  86. md: 12,
  87. options: this.classifyList.map(item=>({label: item.name,value: item.categoryId})),
  88. attributes: { disabled: this.disabled },
  89. formItemAttributes: { label: '商品分类', prop: 'categoryId' },
  90. events: {
  91. change: (val) => {
  92. this.formData.categoryName = this.classifyList.find(item=>item.categoryId == val)?.name
  93. }
  94. }
  95. },
  96. {
  97. name: 'el-radio',
  98. options: this.publishStatus,
  99. attributes: { disabled: true },
  100. md: 12,
  101. formItemAttributes: { label: '发布状态', prop: 'status' }
  102. },
  103. {
  104. name: 'el-input',
  105. md: 12,
  106. attributes: { disabled: this.disabled },
  107. formItemAttributes: { label: '商品名称', prop: 'goodsName' }
  108. },
  109. {
  110. name: 'el-input',
  111. md: 12,
  112. attributes: { disabled: this.disabled, type: 'textarea' },
  113. formItemAttributes: { label: '商品描述', prop: 'goodsNote' }
  114. },
  115. {
  116. name: 'el-input',
  117. md: 6,
  118. attributes: { disabled: this.disabled },
  119. formItemAttributes: { label: '商品价格', prop: 'price' }
  120. },
  121. {
  122. name: 'el-input',
  123. md: 6,
  124. attributes: { disabled: this.disabled },
  125. formItemAttributes: { label: '上架数量', prop: 'qty' }
  126. },
  127. {
  128. name: 'el-input',
  129. md: 6,
  130. attributes: { disabled: this.disabled },
  131. formItemAttributes: { label: '商品品牌', prop: 'brand' }
  132. },
  133. {
  134. name: 'el-input',
  135. md: 6,
  136. attributes: { disabled: this.disabled },
  137. formItemAttributes: { label: '功率(W)', prop: 'power' }
  138. },
  139. {
  140. name: 'el-date-picker',
  141. md: 6,
  142. attributes: { disabled: this.disabled, type:"date", style:{width:'100%'}, "value-format":"yyyy-MM-dd" },
  143. formItemAttributes: { label: '制造日期', prop: 'makeDate' }
  144. },
  145. {
  146. name: 'el-input',
  147. md: 6,
  148. attributes: { disabled: this.disabled },
  149. formItemAttributes: { label: '联系电话', prop: 'linkPhone' }
  150. },
  151. {
  152. name: 'el-input',
  153. md: 6,
  154. attributes: { disabled: true },
  155. formItemAttributes: { label: '点赞量', prop: 'likeCount' }
  156. },
  157. {
  158. name: 'slot-component',
  159. md: 6,
  160. attributes: { disabled: true, placeholder: '' },
  161. formItemAttributes: { label: '留言量', prop: '' },
  162. render: (h, { props }) => {
  163. return (
  164. <el-input
  165. value={Number(this.formData?.messageList?.length)}
  166. disabled={true}
  167. size="mini"
  168. placeholder=""
  169. ></el-input>
  170. )
  171. },
  172. },
  173. {
  174. name: 'el-input',
  175. md: 6,
  176. attributes: { disabled: true },
  177. formItemAttributes: { label: '出售数量', prop: 'goumaiNum' }
  178. },
  179. {
  180. name: 'el-radio',
  181. options: [
  182. { label: '一级能效', value: "一级能效" },
  183. { label: '二级能效', value: "二级能效" },
  184. { label: '三级能效', value: "三级能效" },
  185. { label: '四级能效', value: "四级能效" },
  186. { label: '五级能效', value: "五级能效" },
  187. ],
  188. md: 18,
  189. attributes: { disabled: this.disabled },
  190. formItemAttributes: { label: '能效标识', prop: 'mark' }
  191. },
  192. {
  193. md: 24,
  194. name: 'slot-component',
  195. formItemAttributes: {
  196. label: '商品图片',
  197. prop: 'imgList',
  198. rules: []
  199. },
  200. render: (h, { props, onInput }) => {
  201. return (
  202. <ImageUpload fileList={this.formData.imgList} limit={100} isEdit={!this.disabled}/>
  203. )
  204. }
  205. }
  206. ]
  207. },
  208. // esOrderInfo
  209. formItems2 () {
  210. return [{
  211. name: 'slot-component',
  212. md: 24,
  213. attributes: { disabled: this.disabled },
  214. formItemAttributes: { label: '', prop: '', 'label-width': '0px' },
  215. render: (h, { props }) => {
  216. return (<div>
  217. <el-row gutter={10}>
  218. <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
  219. <div class='info'>
  220. <div class='info_title'>卖家信息</div>
  221. <div class='info_bottom'>
  222. <div class='info_bottom_lt'>
  223. {this?.formData?.esOrderInfo?.sellUrl ? <el-image
  224. style='width: 40px; height: 40px'
  225. src={this?.formData?.esOrderInfo?.sellUrl}
  226. >
  227. </el-image>:null}
  228. </div>
  229. <div class='info_bottom_rt'>
  230. <div>微信昵称:{this?.formData?.esOrderInfo?.sellName}</div>
  231. <div>微信手机号:{this?.formData?.esOrderInfo?.sellMobile}</div>
  232. <div>发布时间:{this?.formData?.esOrderInfo?.sellTime}</div>
  233. </div>
  234. </div>
  235. </div>
  236. </el-col>
  237. <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
  238. <div class='info'>
  239. <div class='info_title'>买家信息</div>
  240. <div class='info_bottom'>
  241. <div class='info_bottom_lt'>
  242. {this?.formData?.esOrderInfo?.wechatUserUrl?<el-image
  243. style='width: 40px; height: 40px'
  244. src={this?.formData?.esOrderInfo?.wechatUserUrl}
  245. >
  246. </el-image>:null}
  247. </div>
  248. <div class='info_bottom_rt'>
  249. <div>微信昵称:{this?.formData?.esOrderInfo?.wechatUserName}</div>
  250. <div>微信手机号:{this?.formData?.esOrderInfo?.wechatUserMobile}</div>
  251. <div>收货人信息:{`(${this?.formData?.esOrderInfo?.userMobile||''}) ${this?.formData?.esOrderInfo?.userMobile||''}`}</div>
  252. <div>收货人地址:{this?.formData?.esOrderInfo?.sellName}</div>
  253. <div>支付方式:{({WECHAT:"微信支付", CASH:"到店支付", TRANSFER:"转账支付"})[this?.formData?.esOrderInfo?.payType]}</div>
  254. </div>
  255. </div>
  256. </div>
  257. </el-col>
  258. {~['SEND','OVER'].indexOf(this?.formData?.esOrderInfo?.status)?<el-col xs={24} sm={24} md={8} lg={8} xl={8}>
  259. <div class='info'>
  260. <div class='info_title'>物流信息</div>
  261. <div class='info_bottom'>
  262. <div class='info_bottom_rt'>
  263. <div>
  264. <el-radio-group disabled={true} value={this?.formData?.esOrderInfo?.logisticsType}>
  265. <el-radio label='SELF'>自提</el-radio>
  266. <el-radio label='DELIVERY'>物流</el-radio>
  267. </el-radio-group>
  268. </div>
  269. {this?.formData?.esOrderInfo?.logisticsType=="DELIVERY"?<div>快递单号:{this?.formData?.esOrderInfo?.logisticsNo}</div>:null}
  270. {this?.formData?.esOrderInfo?.logisticsType=="DELIVERY"?<div>快递公司:{this?.formData?.esOrderInfo?.logisticsName}</div>:null}
  271. {this?.formData?.esOrderInfo?.logisticsType=="DELIVERY"?<el-button type='primary' size='small' onClick={() => {
  272. this.$router.push({
  273. name: 'orderManagement',
  274. params: {
  275. pageName: this?.formData?.esOrderInfo?.esOrderId,
  276. pageType: 'materialFlow',
  277. pageCode: this?.formData?.esOrderInfo?.esOrderId,
  278. },
  279. })
  280. }}>查看物流
  281. </el-button>:null}
  282. </div>
  283. </div>
  284. </div>
  285. </el-col>:null}
  286. </el-row>
  287. </div>)
  288. }
  289. }]
  290. },
  291. formItems3() {
  292. return [{
  293. name: 'slot-component',
  294. md: 24,
  295. attributes: { disabled: this.disabled },
  296. formItemAttributes: { label: '', prop: 'messageList', 'label-width': '0px' },
  297. render: (h, { props }) => {
  298. var { formData } = props
  299. return <div>
  300. <zj-table
  301. columns={[
  302. {
  303. columnAttributes: {
  304. label: '留言人名称',
  305. prop: 'createBy'
  306. }
  307. },
  308. {
  309. columnAttributes: {
  310. label: '留言内容',
  311. prop: 'content'
  312. }
  313. },
  314. {
  315. columnAttributes: {
  316. label: '留言时间',
  317. prop: 'createTime'
  318. }
  319. },
  320. {
  321. columnAttributes: {
  322. label: '回复人名称',
  323. prop: 'replyBy'
  324. }
  325. },
  326. {
  327. columnAttributes: {
  328. label: '回复内容',
  329. prop: 'replyContent'
  330. }
  331. },
  332. {
  333. columnAttributes: {
  334. label: '回复时间',
  335. prop: 'replyTime'
  336. }
  337. },
  338. {
  339. columnAttributes: {
  340. label: '操作',
  341. },
  342. render: (h, { row, column, index }) => {
  343. return <div style="padding-left:10px">
  344. <el-button type="text" onClick={() => {this.msgSend(row)}}>回复</el-button>
  345. </div>
  346. }
  347. }
  348. ]}
  349. tableData={this.formData.messageList}>
  350. </zj-table>
  351. </div>
  352. }
  353. }]
  354. },
  355. },
  356. watch: {
  357. detailId: {
  358. handler(newVal, oldVal) {
  359. if (!newVal) {
  360. return
  361. }
  362. esGoodsDetail({ id: newVal }).then(res => {
  363. this.formData = {
  364. ...res.data,
  365. goumaiNum: res.data?.esOrderInfo?.num || '',
  366. imgList: res.data.imgList.map(item => {
  367. return {
  368. ...item,
  369. url: item.imgUrl,
  370. }
  371. })
  372. }
  373. this.cpdata = JSON.parse(JSON.stringify(res.data))
  374. })
  375. },
  376. deep: true,
  377. immediate: true,
  378. }
  379. },
  380. created(){
  381. getClassifyList({
  382. status:true,
  383. type:5
  384. }).then(res=>{
  385. this.classifyList = res.data
  386. })
  387. },
  388. methods: {
  389. msgSend(row){
  390. this.$prompt('留言回复', '回复', {
  391. confirmButtonText: '确定',
  392. cancelButtonText: '取消',
  393. inputType: "textarea"
  394. }).then(({ value }) => {
  395. if(value){
  396. esGoodsReply({
  397. id:this.detailId,
  398. messageId:row.id,
  399. content:value
  400. }).then(res => {
  401. this.$message({ type: 'success', message: `设置成功!` })
  402. esGoodsDetail({ id: this.detailId }).then(res2 => {
  403. this.formData = {
  404. ...res2.data,
  405. imgList: res2.data.imgList.map(item => {
  406. return {
  407. ...item,
  408. url: item.imgUrl
  409. }
  410. })
  411. }
  412. })
  413. })
  414. }
  415. })
  416. },
  417. copyGoods() {
  418. esGoodsCopy({ id: this.detailId }).then(res => {
  419. this.$message({ type: 'success', message: `克隆成功!` })
  420. this.$emit('back',{detailId:res.data})
  421. })
  422. },
  423. setStatus(status){
  424. esGoodsBatchUpdateStatus({ ids: this.detailId, status:status }).then(res => {
  425. this.$message({ type: 'success', message: `设置成功!` })
  426. this.handleClose()
  427. })
  428. },
  429. handleSubmit() {
  430. this.$refs.formRef.validate((valid) => {
  431. if (valid) {
  432. esGoodsUpdate({
  433. ...this.formData,
  434. imgList: this.formData.imgList.map(item=>({...item, imgUrl:item.url}))
  435. }).then(res=>{
  436. this.$message({ type: 'success', message: `成功!` })
  437. this.$emit('back')
  438. })
  439. }
  440. });
  441. },
  442. handleClose() {
  443. this.$emit('back')
  444. },
  445. zhuanxiaoshou(){
  446. this.$router.push({
  447. name: 'orderManagement',
  448. params: {
  449. pageName: this.detailId,
  450. pageType: 'add',
  451. pageCode: this.detailId,
  452. },
  453. })
  454. }
  455. }
  456. }
  457. </script>
  458. <style lang="scss">
  459. .info {
  460. .info_title {
  461. font-size: 16px;
  462. font-weight: 700;
  463. }
  464. .info_bottom {
  465. display: flex;
  466. margin: 10px 0;
  467. .info_bottom_lt {
  468. width: 40px;
  469. height: 40px;
  470. }
  471. .info_bottom_rt {
  472. padding: 0 0 0 10px;
  473. line-height: 30px;
  474. .photoPZ {
  475. display: inline-block;
  476. vertical-align: text-top;
  477. }
  478. }
  479. }
  480. }
  481. </style>
  482. <style lang="scss" scoped>
  483. .neibuview {
  484. box-sizing: border-box;
  485. padding-left: 16px;
  486. ::v-deep &>.zj-page-fill-scroll {
  487. box-sizing: border-box;
  488. padding-right: 16px;
  489. &>div:nth-child(1) {
  490. margin-top: 20px;
  491. }
  492. }
  493. }
  494. .header1style {
  495. text-align: right;
  496. font-size: 12px;
  497. color: red;
  498. line-height: 18px;
  499. }
  500. .my-module {
  501. ::v-deep .el-form-item__content {
  502. margin-left: 12px !important;
  503. }
  504. }
  505. </style>