AfterSales.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="after_sales">
  3. <view class="sales_info" v-if="tableList.length > 0">
  4. <view>名称:{{ fieldRow('categoryName') }}</view>
  5. <view>类型:{{ fieldRow('productCategoryName') }}</view>
  6. <view>编码:{{ fieldRow('categoryCode') }}</view>
  7. <view>发货条码:{{ fieldRow('barcodes') }}</view>
  8. <view>发货时间:{{ fieldRow('shipmentDate') }}</view>
  9. <view>质保有效期:{{ fieldRow('guaranteePeriodDeadline') }}</view>
  10. <view>计量数量:{{ fieldRow('measureQuantity') }}</view>
  11. <view class="action" v-if="type != 'view'">
  12. <text class="text">
  13. 操作:
  14. </text>
  15. <u-button @click="goProblem('add')" :plain="true" :hairline="true" size='mini' type="default"
  16. text="添加故障"></u-button>
  17. <u-button v-if="!isReport" @click="del" :plain="true" :hairline="true" size='mini' type="default"
  18. class="delete" text="删除"></u-button>
  19. </view>
  20. </view>
  21. <div class="wapper">
  22. <view v-for="(item, index) in faultDetails" :key="index" class="view_box" style="position: relative;">
  23. <myCard @edit="goProblem('edit',index,item)" @del="delProblem(index)" :item="item" :index="index+1"
  24. :columns="columns" :btnList="btnData">
  25. <view class="images" slot="imageUrl">
  26. <PreviewPhoto type="view" :imageList="imagesData(item)" />
  27. </view>
  28. </myCard>
  29. </view>
  30. </div>
  31. </view>
  32. </template>
  33. <script>
  34. import PreviewPhoto from "@/pages/maintenance/check/components/PreviewPhoto.vue"
  35. import myCard from '@/pages/saleManage/components/myCard.vue'
  36. export default {
  37. components: {
  38. myCard,
  39. PreviewPhoto
  40. },
  41. props: {
  42. itemList: {
  43. type: Array,
  44. default: () => []
  45. },
  46. type: {
  47. type: String,
  48. default: 'edit'
  49. },
  50. // 是否是售后工单的 报工或者修改进入
  51. isReport: {
  52. type: Boolean,
  53. default: false
  54. }
  55. },
  56. watch: {
  57. itemList: {
  58. handler(newVal) {
  59. let list = JSON.parse(JSON.stringify(newVal));
  60. list.map((el) => {
  61. el.faultDetails = el.faultDetails ? el.faultDetails : []
  62. })
  63. this.tableList = list
  64. },
  65. deep: true,
  66. immediate: true
  67. }
  68. },
  69. computed: {
  70. faultDetails() {
  71. if (this.tableList.length > 0) {
  72. return this.tableList[0].faultDetails
  73. }
  74. return []
  75. },
  76. fieldRow() {
  77. return (field) => {
  78. if (this.tableList.length == 0) return '';
  79. return this.tableList[0][field]
  80. }
  81. },
  82. btnData() {
  83. if (this.type == 'view') {
  84. return []
  85. }
  86. if (this.isReport) {
  87. this.btnList[1].judge = [{
  88. authorities: '',
  89. }, {
  90. key: 'customize',
  91. value: ['5'],
  92. }]
  93. }
  94. return this.btnList;
  95. },
  96. imagesData() {
  97. return (item) => {
  98. console.log(item, 'item')
  99. let list = item.imageUrl || [];
  100. return list;
  101. }
  102. }
  103. },
  104. data() {
  105. return {
  106. typeOptions: [{
  107. text: '维修',
  108. value: '1'
  109. },
  110. {
  111. text: '保养',
  112. value: '2'
  113. },
  114. {
  115. text: '安装',
  116. value: '3'
  117. }
  118. ],
  119. columns: [
  120. [{
  121. label: '故障类型:',
  122. prop: 'type',
  123. className: 'perce100',
  124. formatter: (row) => {
  125. const user = this.typeOptions.find(item => item.value === row.type);
  126. return user.text
  127. }
  128. }],
  129. [{
  130. label: '故障现象:',
  131. prop: 'faultPhenomenon',
  132. }],
  133. [{
  134. label: '故障原因:',
  135. prop: 'faultReason'
  136. }],
  137. [{
  138. label: '维修过程:',
  139. prop: 'maintenanceProcess',
  140. }],
  141. [{
  142. label: '图片:',
  143. prop: 'maintenanceProcess',
  144. slot: 'imageUrl',
  145. className: 'perce100 image_url',
  146. }],
  147. [{
  148. label: '操作:',
  149. prop: 'action',
  150. type: this.type != 'view' ? 'action' : '',
  151. className: 'perce100',
  152. }],
  153. ],
  154. btnList: [{
  155. name: '编辑',
  156. apiName: 'edit',
  157. btnType: 'error',
  158. type: '2',
  159. pageUrl: '',
  160. },
  161. {
  162. name: '删除',
  163. apiName: 'del',
  164. btnType: 'error',
  165. type: '2',
  166. pageUrl: '',
  167. }
  168. ],
  169. tableList: []
  170. }
  171. },
  172. onLoad({}) {},
  173. created() {
  174. uni.$off('updateFaultList')
  175. uni.$on('updateFaultList', ({
  176. type,
  177. data,
  178. index
  179. }) => {
  180. console.log(data, 'datadatadatadatadatadata')
  181. if (type == 'add' || type == 'report') {
  182. if (this.isReport) {
  183. data.customize = '5'
  184. }
  185. this.tableList[0].faultDetails.push(data)
  186. } else {
  187. this.$set(this.tableList[0].faultDetails, index, data)
  188. }
  189. })
  190. },
  191. methods: {
  192. del() {
  193. uni.showModal({
  194. title: '确认删除',
  195. content: '确定要删除这条售后对象吗?',
  196. confirmText: '删除',
  197. confirmColor: '#FF4D4F',
  198. success: (res) => {
  199. if (res.confirm) {
  200. this.tableList = [];
  201. } else if (res.cancel) {
  202. // 用户点击了取消按钮
  203. console.log('用户取消删除');
  204. }
  205. }
  206. });
  207. },
  208. // 删除故障
  209. delProblem(index) {
  210. uni.showModal({
  211. title: '确认删除',
  212. content: '确定要删除这条故障吗?',
  213. confirmText: '删除',
  214. confirmColor: '#FF4D4F',
  215. success: (res) => {
  216. if (res.confirm) {
  217. this.tableList[0].faultDetails.splice(index, 1);
  218. } else if (res.cancel) {
  219. // 用户点击了取消按钮
  220. console.log('用户取消删除');
  221. }
  222. }
  223. });
  224. },
  225. // 现在只针对做 一 对 多 的 故障数据
  226. goProblem(type, index, obj = {}) {
  227. let str = this.type == 'report' ? 'report' : '';
  228. let resD = JSON.parse(JSON.stringify(obj));
  229. let arr = [];
  230. if (resD.imageUrl && resD.imageUrl.length > 0) {
  231. arr = JSON.stringify(resD.imageUrl);
  232. delete resD.imageUrl;
  233. }
  234. console.log(arr, 'arr ----')
  235. let data = JSON.stringify(resD);
  236. uni.navigateTo({
  237. url: `/pages/salesServiceManagement/demandList/components/faultAdd?type=${type}&index=${index}&data=${data}&str=${str}&arr=${encodeURIComponent(arr)}`
  238. })
  239. },
  240. addFault() {
  241. },
  242. // 返回列表数据
  243. getTabData() {
  244. if (!this.isReport) return this.tableList || [];
  245. let list = this.tableList.map((el) => {
  246. if (el.customize) {
  247. delete el.customize;
  248. }
  249. return el;
  250. })
  251. return list;
  252. }
  253. },
  254. }
  255. </script>
  256. <style lang="scss" scoped>
  257. .after_sales {
  258. height: calc(100vh - 246rpx);
  259. .sales_info {
  260. padding: 8px 16px;
  261. font-size: 13px;
  262. font-style: normal;
  263. font-weight: 400;
  264. line-height: 22px;
  265. word-wrap: break-word;
  266. border-bottom: 6rpx solid #E1E1E1;
  267. .action {
  268. display: flex;
  269. line-height: 22px;
  270. .text {
  271. margin-right: 12rpx;
  272. }
  273. /deep/ .u-button {
  274. width: 100rpx;
  275. font-size: 26rpx;
  276. margin-left: 10rpx;
  277. margin-right: 0rpx;
  278. background: #157a2c;
  279. color: #fff !important;
  280. }
  281. }
  282. }
  283. .wapper {
  284. height: calc(100% - 338rpx);
  285. .view_box {
  286. /deep/ .card_box {
  287. .image_url {
  288. width: 110%;
  289. .item_one {
  290. .text {
  291. display: block;
  292. width: calc(100% - 80rpx);
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. }
  300. </style>