form.vue 14 KB

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