AfterSales.vue 5.7 KB

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