index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div>
  3. <el-button size="small" type="primary" @click="onShow" >{{title}}</el-button>
  4. <el-drawer
  5. title="添加商品"
  6. :visible.sync="dialogFormVisible"
  7. size="90%"
  8. direction="rtl"
  9. :show-close="false"
  10. append-to-body
  11. @close="onClose">
  12. <div class="drawer__panel" style="padding-bottom: 36px;">
  13. <div class="flex-between">
  14. <uploadAllData
  15. class="inline-16"
  16. :total="total"
  17. @handlePullApi="handlePullApi"
  18. @handleUploadApi="handleUploadApi"
  19. @onSuccess="onSuccess"
  20. ></uploadAllData>
  21. <el-button :disabled="items.length === 0" :type="items.length > 0?'primary':''" size="small" class="inline-24 bottom-margin" @click="batchAdd">添加选中商品</el-button>
  22. <el-input style="width:200px;" placeholder="商品名称/编码/品号" :suffix-icon="params.content.where.condition?params.content.where.condition.length > 0?'':'':'el-icon-search'" v-model="params.content.where.condition" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="input-with-select inline-24 layout_search__panel bottom-margin" clearable>
  23. </el-input>
  24. <el-input style="width:200px;" placeholder="型号" :suffix-icon="params.content.where.model?params.content.where.model.length > 0?'':'':'el-icon-search'" v-model="params.content.where.model" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
  25. </el-input>
  26. <el-input style="width:200px;" placeholder="规格" :suffix-icon="params.content.where.spec?params.content.where.spec.length > 0?'':'':'el-icon-search'" v-model="params.content.where.spec" @keyup.native.enter="listData(params.content.pageNumber = 1)" @clear="listData(params.content.pageNumber = 1)" size="small" class="bottom-margin input-with-select inline-24 layout_search__panel" clearable>
  27. </el-input>
  28. <slot name="optionSystem"></slot>
  29. </div>
  30. <selectClass ref="class" @clickAreaBase="clickAreaBase" @brandChange="brandChange" @onClassChange="onClassChange" @Search="Search" @clearSearch="clearSearch" @clickField="clickField" :default="true"></selectClass>
  31. <div style="width: 100%;border-bottom: 1px solid #ebeef5;margin-bottom: 10px;"></div>
  32. <div >
  33. <tableTemp ref="tableTemp" :data="list" :layout="tablecolsAdd" :opwidth="200" :custom="true" height="calc(100vh - 370px)" @checkboxCallBack="checkboxCallBack" fixedName="operation">
  34. <template v-slot:customcol="scope">
  35. <p v-if="scope.column.columnname === 'cover'">
  36. <previewImage v-if="scope.column.data.attinfos[0]" class="image" :image="scope.column.data.attinfos[0]" :list="scope.column.data.attinfos" :deletebtn="false"></previewImage>
  37. </p>
  38. <p v-else>{{scope.column.data[scope.column.columnname]}}</p>
  39. </template>
  40. <template v-slot:opreation="scope">
  41. <el-button type="text" size="mini" @click="addProduct(scope)">添 加</el-button>
  42. </template>
  43. </tableTemp>
  44. <div class="container normal-panel" style="text-align:right">
  45. <el-pagination
  46. background
  47. @size-change="handleSizeChange"
  48. @current-change="handleCurrentChange"
  49. :current-page="params.content.pageNumber"
  50. :page-sizes="[20, 50, 100, 200]"
  51. :page-size="100"
  52. layout="total,sizes, prev, pager, next, jumper"
  53. :total="total">
  54. </el-pagination>
  55. </div>
  56. </div>
  57. </div>
  58. </el-drawer>
  59. </div>
  60. </template>
  61. <script>
  62. import tableTemp from './table'
  63. import uploadAllData from '@/components/uploadAllData/index'
  64. import previewImage from '@/components/previewImage/index'
  65. import selectClass from '@/SDrpManagement/ProductGroup/modules/Select2.vue'
  66. export default {
  67. name: "index",
  68. props:["data","tradefield","discountrate","params","title","tablecolsAdd","sa_projectid","querySa_brandid","typeName"],
  69. components:{tableTemp,uploadAllData,previewImage,selectClass},
  70. provide () {
  71. return {
  72. sys_enterpriseid:() => ''
  73. }
  74. },
  75. data(){
  76. return {
  77. dialogFormVisible:false,
  78. sa_brandid:'',
  79. itemclassid:'',
  80. itemstandard:'',
  81. itemmaterial:'',
  82. list:[],
  83. total:0,
  84. options:{
  85. brands:[],
  86. itemclass:[],
  87. itemstandards:[],
  88. itemmaterials:[]
  89. },
  90. items:[]
  91. }
  92. },
  93. methods:{
  94. onShow(){
  95. this.dialogFormVisible = true
  96. this.$store.dispatch('optiontypeselect','itemstandards').then(res=>{
  97. this.options.itemstandards = res.data
  98. })
  99. this.$store.dispatch('optiontypeselect','itemmaterial').then(res=>{
  100. this.options.itemmaterials = res.data
  101. })
  102. this.querySa_brandid !== '' ?this.sa_brandid = this.querySa_brandid : this.sa_brandid = ''
  103. this.queryBrands()
  104. this.queryClass()
  105. this.listData(this.params.content.pageNumber = 1)
  106. },
  107. /*可添加商品*/
  108. async listData(){
  109. if (this.data){
  110. switch (this.data.type) {
  111. case '标准订单':
  112. this.params.id = 20221109153502
  113. break;
  114. case '项目订单':
  115. this.params.id = 20230103155002
  116. break;
  117. case '促销订单':
  118. this.params.id = 20230107182302
  119. break;
  120. case '工具订单':
  121. this.params.id = 20221109153502
  122. break;
  123. default:
  124. this.params.id = 20221109153502
  125. break;
  126. }
  127. }
  128. if (this.typeName === '居间'){
  129. this.params.id = 20221124093602
  130. }
  131. console.log(this.params.id);
  132. this.params.content.where.tradefield = this.tradefield
  133. const res = await this.$api.requested(this.params)
  134. this.list = res.data
  135. this.total = res.total
  136. this.$refs.tableTemp.$refs.table.doLayout()
  137. },
  138. /*获取品牌*/
  139. async queryBrands () {
  140. const res = await this.$api.requested({
  141. "id": "20220924163702",
  142. "content": {
  143. "pageSize":1000,
  144. "where":{
  145. "condition":""
  146. }
  147. }
  148. })
  149. this.options.brands = res.data
  150. console.log("获取品牌",res.data)
  151. this.sa_brandid = res.data[0].sa_brandid
  152. this.queryClass()
  153. },
  154. /*获取分类*/
  155. async queryClass () {
  156. const res = await this.$api.requested({
  157. "id":"20220922110403",
  158. "content":{
  159. "sa_brandid":this.sa_brandid !== '' ? this.sa_brandid : 0
  160. }
  161. })
  162. let arr = []
  163. function converTree(node) {
  164. var elNode = {
  165. isdeep:node["isdeep"],
  166. ishide:node["ishide"],
  167. istool:node["istool"],
  168. itemclassfullname:node["itemclassfullname"],
  169. itemclassfullnum:node["itemclassfullnum"],
  170. itemclassid:node["itemclassid"],
  171. itemclassname:node["itemclassname"],
  172. itemclassnum:node["itemclassnum"],
  173. num:node["num"],
  174. parentid:node["parentid"],
  175. rowindex:node["rowindex"],
  176. subdep:[]
  177. }
  178. if (node.subdep.length > 0) {
  179. // 如果存在子节点
  180. for (var index = 0; index < node.subdep.length; index++) {
  181. // 遍历子节点, 把每个子节点看做一颗独立的树, 传入递归构造子树, 并把结果放回到新node的children中
  182. elNode.subdep.push(converTree(node.subdep[index]));
  183. }
  184. }else {
  185. elNode = {
  186. isdeep:node["isdeep"],
  187. ishide:node["ishide"],
  188. istool:node["istool"],
  189. itemclassfullname:node["itemclassfullname"],
  190. itemclassfullnum:node["itemclassfullnum"],
  191. itemclassid:node["itemclassid"],
  192. itemclassname:node["itemclassname"],
  193. itemclassnum:node["itemclassnum"],
  194. num:node["num"],
  195. parentid:node["parentid"],
  196. rowindex:node["rowindex"],
  197. }
  198. }
  199. return elNode;
  200. }
  201. // this.options.itemclass = arr
  202. res.data[0].ttemclass.forEach(e=>{
  203. arr.push(converTree(e))
  204. });
  205. this.options.itemclass = arr
  206. return arr
  207. },
  208. brandChange(id){
  209. this.params.content.where.sa_brandid = this.params.id == 20221021171802 ?id[0]:id
  210. this.$refs.class.clickClass(false)
  211. this.listData(this.params.content.pageNumber = 1)
  212. },
  213. onClassChange (n) {
  214. this.params.content.where.itemclassid = n.itemclassid
  215. this.listData(this.params.content.pageNumber = 1)
  216. },
  217. clickField (item) {
  218. this.params.content.where.tradefield = item.tradefield
  219. this.listData(this.params.content.pageNumber = 1)
  220. },
  221. clickAreaBase (item) {
  222. this.params.content.where.standards = item
  223. this.listData(this.params.content.pageNumber = 1)
  224. },
  225. Search(data) {
  226. this.params.content.where.condition = data
  227. this.params.content.pageNumber = 1
  228. this.listData(this.params.content.pageNumber = 1)
  229. },
  230. clearSearch() {
  231. this.params.content.where.condition = ''
  232. this.params.content.pageNumber = 1
  233. this.listData(this.params.content.pageNumber = 1)
  234. },
  235. classChange(){
  236. this.params.content.where.itemclassid = this.itemclassid[this.itemclassid.length -1]
  237. this.listData(this.params.content.pageNumber = 1)
  238. },
  239. queryChange(){
  240. this.params.content.where.standards = this.itemstandard
  241. this.params.content.where.material = this.itemmaterial
  242. this.listData(this.params.content.pageNumber = 1)
  243. },
  244. /*拉取数据*/
  245. handlePullApi (pullApi) {
  246. pullApi.content = JSON.parse(JSON.stringify(this.params.content))
  247. pullApi.id = this.params.id
  248. /*pullApi.content.sa_projectid = this.$route.query.id*/
  249. },
  250. /*上传数据*/
  251. handleUploadApi (uploadApi,data) {
  252. this.$emit('uploadData',uploadApi,data)
  253. },
  254. /*勾选*/
  255. checkboxCallBack(val){
  256. this.items = val
  257. },
  258. /*批量添加*/
  259. batchAdd(){
  260. console.log(this.items,'item')
  261. this.$emit('addSuccess',this.items)
  262. },
  263. /*添加商品*/
  264. addProduct(val){
  265. console.log(val,'添加商品')
  266. this.items = val
  267. this.$emit('addProduct',this.items.data)
  268. },
  269. onSuccess () {
  270. console.log('成功')
  271. this.listData(this.params.content.pageNumber = 1)
  272. },
  273. onClose(){
  274. this.dialogFormVisible = false
  275. this.sa_brandid = ''
  276. this.itemclassid = ''
  277. this.itemstandard = ''
  278. this.itemmaterial = ''
  279. this.$emit("closeDrawer")
  280. },
  281. handleSizeChange(val) {
  282. // console.log(`每页 ${val} 条`);
  283. this.params.content.pageSize = val
  284. this.listData()
  285. },
  286. handleCurrentChange(val) {
  287. // console.log(`当前页: ${val}`);
  288. this.params.content.pageNumber = val
  289. this.listData()
  290. },
  291. },
  292. mounted() {
  293. },
  294. created() {
  295. }
  296. }
  297. </script>
  298. <style scoped>
  299. .image{
  300. height: 38px;
  301. width: 38px;
  302. margin-top:0;
  303. }
  304. .top-margin{
  305. margin-top: 20px;
  306. }
  307. .bottom-margin{
  308. margin-bottom: 10px;
  309. }
  310. /deep/ input::-webkit-input-placeholder {
  311. color: #58585d;
  312. }
  313. /deep/ input::-moz-input-placeholder {
  314. color: #58585d;
  315. }
  316. /deep/ input::-ms-input-placeholder {
  317. color: #58585d;
  318. }
  319. </style>