form.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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 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', 'OFF'].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/Common/image-upload.vue'
  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: this.disabled },
  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-input',
  141. md: 6,
  142. attributes: { disabled: this.disabled },
  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-radio',
  175. options: [
  176. { label: '一级能效', value: "一级能效" },
  177. { label: '二级能效', value: "二级能效" },
  178. { label: '三级能效', value: "三级能效" },
  179. { label: '四级能效', value: "四级能效" },
  180. { label: '五级能效', value: "五级能效" },
  181. ],
  182. md: 24,
  183. attributes: { disabled: this.disabled },
  184. formItemAttributes: { label: '能效标识', prop: 'mark' }
  185. },
  186. {
  187. md: 24,
  188. name: 'slot-component',
  189. formItemAttributes: {
  190. label: '商品图片',
  191. prop: 'imgList',
  192. rules: []
  193. },
  194. render: (h, { props, onInput }) => {
  195. return (
  196. <ImageUpload fileList={this.formData.imgList} limit={100} isEdit={!this.disabled}/>
  197. )
  198. }
  199. }
  200. ]
  201. },
  202. // esOrderInfo
  203. formItems2 () {
  204. return [{
  205. name: 'slot-component',
  206. md: 24,
  207. attributes: { disabled: this.disabled },
  208. formItemAttributes: { label: '', prop: '', 'label-width': '0px' },
  209. render: (h, { props }) => {
  210. return (<div>
  211. <el-row gutter={10}>
  212. <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
  213. <div class='info'>
  214. <div class='info_title'>卖家信息</div>
  215. <div class='info_bottom'>
  216. <div class='info_bottom_lt'>
  217. <el-image
  218. style='width: 40px; height: 40px'
  219. src={this?.formData?.esOrderInfo?.sellUrl}
  220. >
  221. </el-image>
  222. </div>
  223. <div class='info_bottom_rt'>
  224. <div>微信昵称:{this?.formData?.esOrderInfo?.sellName}</div>
  225. <div>微信手机号:{this?.formData?.esOrderInfo?.sellMobile}</div>
  226. <div>发布时间:{this?.formData?.esOrderInfo?.sellTime}</div>
  227. </div>
  228. </div>
  229. </div>
  230. </el-col>
  231. <el-col xs={24} sm={24} md={8} lg={8} xl={8}>
  232. <div class='info'>
  233. <div class='info_title'>买家信息</div>
  234. <div class='info_bottom'>
  235. <div class='info_bottom_lt'>
  236. <el-image
  237. style='width: 40px; height: 40px'
  238. src={this?.formData?.esOrderInfo?.wechatUserUrl}
  239. >
  240. </el-image>
  241. </div>
  242. <div class='info_bottom_rt'>
  243. <div>微信昵称:{this?.formData?.esOrderInfo?.wechatUserName}</div>
  244. <div>微信手机号:{this?.formData?.esOrderInfo?.wechatUserMobile}</div>
  245. <div>收货人信息:{`(${this?.formData?.esOrderInfo?.userMobile||''}) ${this?.formData?.esOrderInfo?.userMobile||''}`}</div>
  246. <div>收货人地址:{this?.formData?.esOrderInfo?.sellName}</div>
  247. <div>支付方式:{({WECHAT:"微信支付", CASH:"到店支付", TRANSFER:"转账支付"})[this?.formData?.esOrderInfo?.payType]}</div>
  248. </div>
  249. </div>
  250. </div>
  251. </el-col>
  252. {~['SEND','OVER'].indexOf(this?.formData?.esOrderInfo?.status)?<el-col xs={24} sm={24} md={8} lg={8} xl={8}>
  253. <div class='info'>
  254. <div class='info_title'>物流信息</div>
  255. <div class='info_bottom'>
  256. <div class='info_bottom_rt'>
  257. <div>
  258. <el-radio-group disabled={true} value={this?.formData?.esOrderInfo?.logisticsType}>
  259. <el-radio label='SELF'>自提</el-radio>
  260. <el-radio label='DELIVERY'>物流</el-radio>
  261. </el-radio-group>
  262. </div>
  263. <div>快递单号:{this?.formData?.esOrderInfo?.logisticsNo}</div>
  264. <div>快递公司:{this?.formData?.esOrderInfo?.logisticsName}</div>
  265. <el-button type='primary' size='small' onClick={() => {
  266. this.$router.push({
  267. name: 'orderManagement',
  268. params: {
  269. pageName: this?.formData?.esOrderInfo?.esOrderId,
  270. pageType: 'materialFlow',
  271. pageCode: this?.formData?.esOrderInfo?.esOrderId,
  272. },
  273. })
  274. }}>查看物流
  275. </el-button>
  276. </div>
  277. </div>
  278. </div>
  279. </el-col>:null}
  280. </el-row>
  281. </div>)
  282. }
  283. }]
  284. },
  285. formItems3() {
  286. return [{
  287. name: 'slot-component',
  288. md: 24,
  289. attributes: { disabled: this.disabled },
  290. formItemAttributes: { label: '', prop: 'messageList', 'label-width': '0px' },
  291. render: (h, { props }) => {
  292. var { formData } = props
  293. return <div>
  294. <zj-table
  295. columns={[
  296. {
  297. columnAttributes: {
  298. label: '留言人名称',
  299. prop: 'createBy'
  300. }
  301. },
  302. {
  303. columnAttributes: {
  304. label: '留言内容',
  305. prop: 'content'
  306. }
  307. },
  308. {
  309. columnAttributes: {
  310. label: '留言时间',
  311. prop: 'createTime'
  312. }
  313. },
  314. {
  315. columnAttributes: {
  316. label: '回复人名称',
  317. prop: 'replyBy'
  318. }
  319. },
  320. {
  321. columnAttributes: {
  322. label: '回复内容',
  323. prop: 'replyContent'
  324. }
  325. },
  326. {
  327. columnAttributes: {
  328. label: '回复时间',
  329. prop: 'replyTime'
  330. }
  331. },
  332. {
  333. columnAttributes: {
  334. label: '操作',
  335. },
  336. render: (h, { row, column, index }) => {
  337. return <div style="padding-left:10px">
  338. <el-button type="text" onClick={() => {this.msgSend(row)}}>回复</el-button>
  339. </div>
  340. }
  341. }
  342. ]}
  343. tableData={this.formData.messageList}>
  344. </zj-table>
  345. </div>
  346. }
  347. }]
  348. },
  349. },
  350. watch: {
  351. detailId: {
  352. handler(newVal, oldVal) {
  353. if (!newVal) {
  354. return
  355. }
  356. esGoodsDetail({ id: newVal }).then(res => {
  357. this.formData = {
  358. ...res.data,
  359. imgList: res.data.imgList.map(item => {
  360. return {
  361. ...item,
  362. url: item.imgUrl
  363. }
  364. })
  365. }
  366. this.cpdata = JSON.parse(JSON.stringify(res.data))
  367. })
  368. },
  369. deep: true,
  370. immediate: true,
  371. }
  372. },
  373. created(){
  374. getClassifyList({
  375. status:true,
  376. type:5
  377. }).then(res=>{
  378. this.classifyList = res.data
  379. })
  380. },
  381. methods: {
  382. msgSend(row){
  383. this.$prompt('留言回复', '回复', {
  384. confirmButtonText: '确定',
  385. cancelButtonText: '取消',
  386. inputType: "textarea"
  387. }).then(({ value }) => {
  388. if(value){
  389. esGoodsReply({
  390. id:this.detailId,
  391. messageId:row.id,
  392. content:value
  393. }).then(res => {
  394. this.$message({ type: 'success', message: `设置成功!` })
  395. esGoodsDetail({ id: this.detailId }).then(res2 => {
  396. this.formData = {
  397. ...res2.data,
  398. imgList: res2.data.imgList.map(item => {
  399. return {
  400. ...item,
  401. url: item.imgUrl
  402. }
  403. })
  404. }
  405. })
  406. })
  407. }
  408. })
  409. },
  410. copyGoods() {
  411. esGoodsCopy({ id: this.detailId }).then(res => {
  412. this.$message({ type: 'success', message: `克隆成功!` })
  413. this.$emit('back',{detailId:res.data})
  414. })
  415. },
  416. setStatus(status){
  417. esGoodsBatchUpdateStatus({ ids: this.detailId, status:status }).then(res => {
  418. this.$message({ type: 'success', message: `设置成功!` })
  419. this.handleClose()
  420. })
  421. },
  422. handleSubmit() {
  423. this.$refs.formRef.validate((valid) => {
  424. if (valid) {
  425. esGoodsUpdate({
  426. ...this.formData,
  427. imgList: this.formData.imgList.map(item=>({...item, imgUrl:item.url}))
  428. }).then(res=>{
  429. this.$message({ type: 'success', message: `成功!` })
  430. this.$emit('back')
  431. })
  432. }
  433. });
  434. },
  435. handleClose() {
  436. this.$emit('back')
  437. },
  438. zhuanxiaoshou(){
  439. this.$router.push({
  440. name: 'orderManagement',
  441. params: {
  442. pageName: this.detailId,
  443. pageType: 'add',
  444. pageCode: this.detailId,
  445. },
  446. })
  447. }
  448. }
  449. }
  450. </script>
  451. <style lang="scss">
  452. .info {
  453. .info_title {
  454. font-size: 16px;
  455. font-weight: 700;
  456. }
  457. .info_bottom {
  458. display: flex;
  459. margin: 10px 0;
  460. .info_bottom_lt {
  461. width: 40px;
  462. height: 40px;
  463. }
  464. .info_bottom_rt {
  465. padding: 0 0 0 10px;
  466. line-height: 30px;
  467. .photoPZ {
  468. display: inline-block;
  469. vertical-align: text-top;
  470. }
  471. }
  472. }
  473. }
  474. </style>
  475. <style lang="scss" scoped>
  476. .neibuview {
  477. box-sizing: border-box;
  478. padding-left: 16px;
  479. ::v-deep &>.zj-page-fill-scroll {
  480. box-sizing: border-box;
  481. padding-right: 16px;
  482. &>div:nth-child(1) {
  483. margin-top: 20px;
  484. }
  485. }
  486. }
  487. .header1style {
  488. text-align: right;
  489. font-size: 12px;
  490. color: red;
  491. line-height: 18px;
  492. }
  493. .my-module {
  494. ::v-deep .el-form-item__content {
  495. margin-left: 12px !important;
  496. }
  497. }
  498. </style>