plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

333 lines
10 KiB

2 years ago
2 years ago
2 years ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. <script>
  2. import {
  3. getTestPropertiesList,
  4. removeTestPropertiesItem,
  5. saveTestPropertiesItem,
  6. searchTestPropertiesItem,
  7. searchTestPropertiesItemList,
  8. searchTestPropertiesList,
  9. updateTestPropertiesList
  10. } from "../../../../api/test/testProperties";
  11. import TransferTable from "../../common/transferTable.vue";
  12. export default {
  13. name: "testProperties",
  14. components: {TransferTable},
  15. props:{
  16. dataList:{
  17. type: Array,
  18. default: ()=>[],
  19. },
  20. testNo:{
  21. type:String,
  22. },
  23. testNumber:{
  24. type:[String,Number],
  25. },
  26. columnList:{
  27. type: Array,
  28. default: ()=>[],
  29. },
  30. height:{
  31. type:[Number,String],
  32. default:300
  33. },
  34. disabled:{
  35. type:Boolean,
  36. default:false
  37. },
  38. },
  39. model:{
  40. prop:"dataList",
  41. event:"change"
  42. },
  43. data(){
  44. return{
  45. loading:false,
  46. attributeDialog:true,
  47. copyAttributeList:[],
  48. attributeSaveDialog:false,
  49. productColumnList: [
  50. {
  51. userId: this.$store.state.user.name,
  52. functionId: 100002001,
  53. serialNumber: '100002001TableItemNo',
  54. tableId: "100002001Table",
  55. tableName: "属性表",
  56. columnProp: 'itemNo',
  57. headerAlign: "center",
  58. align: "left",
  59. columnLabel: '属性编码',
  60. columnHidden: false,
  61. columnImage: false,
  62. columnSortable: false,
  63. sortLv: 0,
  64. status: true,
  65. fixed: '',
  66. },{
  67. userId: this.$store.state.user.name,
  68. functionId: 100002001,
  69. serialNumber: '100002001TableItemDesc',
  70. tableId: "100002001Table",
  71. tableName: "属性表",
  72. columnProp: 'itemDesc',
  73. headerAlign: "center",
  74. align: "left",
  75. columnLabel: '属性名称',
  76. columnHidden: false,
  77. columnImage: false,
  78. columnSortable: false,
  79. sortLv: 0,
  80. status: true,
  81. fixed: '',
  82. },
  83. {
  84. userId: this.$store.state.user.name,
  85. functionId: 100002001,
  86. serialNumber: '100002001TableValueType',
  87. tableId: "100002001Table",
  88. tableName: "属性表",
  89. columnProp: 'valueType',
  90. headerAlign: "center",
  91. align: "center",
  92. columnLabel: '值类型',
  93. columnHidden: false,
  94. columnImage: false,
  95. columnSortable: false,
  96. sortLv: 0,
  97. status: true,
  98. fixed: '',
  99. columnWidth:80,
  100. },
  101. {
  102. userId: this.$store.state.user.name,
  103. functionId: 100002001,
  104. serialNumber: '100002001TableMaxValue',
  105. tableId: "100002001Table",
  106. tableName: "属性表",
  107. columnProp: 'textValue',
  108. headerAlign: "center",
  109. align: "left",
  110. columnLabel: '属性值',
  111. columnHidden: false,
  112. columnImage: false,
  113. columnSortable: false,
  114. sortLv: 0,
  115. status: true,
  116. fixed: '',
  117. columnWidth:120,
  118. },
  119. ],
  120. searchDataList:[],
  121. }
  122. },
  123. methods:{
  124. searchAttributeList(data){
  125. let params= JSON.parse(JSON.stringify(data))
  126. params.site=this.$store.state.user.site;
  127. params.list = this.dataList;
  128. if (!this.attributeSaveDialog){
  129. this.searchDataList = [];
  130. }
  131. searchTestPropertiesItemList(params).then(({data}) => {
  132. if (data && data.code === 0){
  133. this.searchDataList = data.rows;
  134. this.attributeSaveDialog = true;
  135. }else {
  136. this.$message.warning(data.msg)
  137. }
  138. }).catch((error)=>{
  139. this.$message.error(error)
  140. })
  141. },
  142. saveTestPropertiesItem(params){
  143. let i = 0;
  144. let arr = params.searchTableList.map(item=>{
  145. item.testNo = this.testNo;
  146. item.seqNo = i++;
  147. return item
  148. })
  149. saveTestPropertiesItem(arr).then(({data})=>{
  150. if (data && data.code === 0){
  151. this.$message.success(data.msg);
  152. this.getTestProperties(params)
  153. }else {
  154. this.$message.warning(data.msg);
  155. }
  156. }).catch((error)=>{
  157. this.$message.error(error)
  158. })
  159. },
  160. getTestProperties(searchData){
  161. let params = {
  162. site:this.$store.state.user.site,
  163. testNo: this.testNo
  164. }
  165. getTestPropertiesList(params).then(({data})=>{
  166. if (data && data.code === 0){
  167. this.$emit("change",data.rows)
  168. if (searchData){
  169. this.$nextTick(()=>{
  170. this.searchAttributeList(searchData)
  171. })
  172. }
  173. }else {
  174. this.$message.warning(data.msg)
  175. }
  176. }).catch((error)=>{
  177. this.$message.error(error)
  178. })
  179. },
  180. updateTestPropertiesList(){
  181. this.loading = true
  182. updateTestPropertiesList(this.copyAttributeList).then(({data})=>{
  183. if (data && data.code === 0){
  184. this.$message.success(data.msg);
  185. this.$emit("change",this.copyAttributeList)
  186. this.getTestProperties();
  187. this.attributeDialog = true;
  188. }else {
  189. this.$message.warning(data.msg);
  190. }
  191. this.loading = false
  192. }).catch((error)=>{
  193. this.$message.error(error)
  194. this.loading = false
  195. })
  196. },
  197. clickSave(){
  198. if (!this.attributeDialog){
  199. this.updateTestPropertiesList();
  200. }else {
  201. this.copyAttributeList = JSON.parse(JSON.stringify(this.dataList))
  202. this.attributeDialog = false;
  203. }
  204. },
  205. clickSaveBtn(){
  206. if (!this.attributeDialog) {
  207. this.$message.warning('请保存更改!')
  208. return
  209. }
  210. //查询 属性模板
  211. this.searchAttributeList({})
  212. },
  213. removeTestPropertiesItem(params){
  214. removeTestPropertiesItem(params.dataTableList).then(({data})=>{
  215. if (data && data.code === 0){
  216. this.$message.success(data.msg);
  217. this.getTestProperties(params)
  218. }else {
  219. this.$message.warning(data.msg);
  220. }
  221. }).catch((error)=>{
  222. this.$message.error(error)
  223. })
  224. }
  225. },
  226. }
  227. </script>
  228. <template>
  229. <div>
  230. <div style="margin-top: 5px">
  231. <template v-if="isAuth('107001:tab1:save')">
  232. <el-button type="primary" @click="clickSaveBtn" v-if="testNo && !disabled">新增</el-button>
  233. </template>
  234. <template v-if="isAuth('107001:tab1:update')">
  235. <el-button type="primary" :loading="loading" v-if="testNo && !disabled" @click="clickSave">{{ attributeDialog?'编辑':'保存' }}</el-button>
  236. </template>
  237. </div>
  238. <div class="rq " v-if="attributeDialog">
  239. <el-table
  240. :height="height"
  241. :data="dataList"
  242. border
  243. style="width: 100%;margin-top: 5px">
  244. <el-table-column
  245. v-for="(item,index) in productColumnList" :key="index"
  246. :sortable="item.columnSortable"
  247. :prop="item.columnProp"
  248. :header-align="item.headerAlign"
  249. :show-overflow-tooltip="item.showOverflowTooltip"
  250. :align="item.align"
  251. :fixed="item.fixed===''?false:item.fixed"
  252. :min-width="item.columnWidth"
  253. :label="item.columnLabel">
  254. <template slot-scope="scope">
  255. <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
  256. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  257. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  258. </div>
  259. <div v-else>
  260. {{scope.row.textValue?scope.row.textValue:scope.row.numValue}}
  261. </div>
  262. </template>
  263. </el-table-column>
  264. </el-table>
  265. </div>
  266. <div class="rq " v-else>
  267. <el-table
  268. :height="height"
  269. :data="copyAttributeList"
  270. border
  271. style="width: 100%;margin-top: 5px">
  272. <el-table-column
  273. v-for="(item,index) in productColumnList" :key="index"
  274. :sortable="item.columnSortable"
  275. :prop="item.columnProp"
  276. :header-align="item.headerAlign"
  277. :show-overflow-tooltip="item.showOverflowTooltip"
  278. :align="item.align"
  279. :fixed="item.fixed===''?false:item.fixed"
  280. :min-width="item.columnWidth"
  281. :label="item.columnLabel">
  282. <template slot-scope="scope">
  283. <div v-if="item.columnProp !== 'textValue' && item.columnProp !== 'numValue'">
  284. <span v-if="!item.columnHidden">{{ scope.row[item.columnProp] }}</span>
  285. <span v-if="item.columnImage"><img :src="scope.row[item.columnProp]" style="width: 100px; height: 80px"/></span>
  286. </div>
  287. <div v-else>
  288. <div v-if="scope.row.valueChooseFlag !== 'Y'">
  289. <el-input-number v-model="scope.row.numValue" style="padding: 0;width: 100%" v-if="scope.row.valueType === '数字'" :controls="false"></el-input-number>
  290. <el-input v-model="scope.row.textValue" v-else></el-input>
  291. </div>
  292. <div v-else>
  293. <el-select style="width: 100%;" v-if="scope.row.valueType === '文本'" v-model="scope.row.textValue">
  294. <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.list" :key="key"></el-option>
  295. </el-select>
  296. <el-select style="width: 100%;" v-else v-model="scope.row.numValue">
  297. <el-option :value="i.availableValue" :label="i.availableValue" v-for="(i,key) in scope.row.list" :key="key"></el-option>
  298. </el-select>
  299. </div>
  300. </div>
  301. </template>
  302. </el-table-column>
  303. </el-table>
  304. </div>
  305. <el-dialog :close-on-click-modal="false" title="属性项目" v-drag :visible.sync="attributeSaveDialog" append-to-body>
  306. <transfer-table v-if="attributeSaveDialog"
  307. v-model="dataList"
  308. :data-list="searchDataList"
  309. @add="saveTestPropertiesItem"
  310. @delete="removeTestPropertiesItem"
  311. @search="searchAttributeList"></transfer-table>
  312. <el-footer style="height:40px;margin-top: 20px;text-align:center">
  313. <el-button type="primary" @click="attributeSaveDialog = false">关闭</el-button>
  314. </el-footer>
  315. </el-dialog>
  316. </div>
  317. </template>
  318. <style scoped>
  319. .el-input-number /deep/ .el-input__inner {
  320. text-align: right;
  321. padding-right: 5px !important;
  322. }
  323. /deep/ .el-input .el-input--medium{
  324. line-height: 20px;
  325. }
  326. /deep/ .el-input-number .el-input--medium{
  327. line-height: 20px;
  328. }
  329. </style>